HJ_Server/src/api_s2c/email/ApiRemove.ts
2023-12-13 20:51:17 +08:00

13 lines
541 B
TypeScript

import { ApiCall } from "tsrpc";
import { EmailFun } from '../../public/email';
import { ReqRemove, ResRemove } from "../../shared/protocols/email/PtlRemove";
export default async function (call: ApiCall<ReqRemove, ResRemove>) {
let email = await EmailFun.getEmail(call.uid, call.req._id);
if (!email) return call.error(globalThis.lng.email_3);
if (email.prizeData?.isGet == false && email.prizeData?.prize?.length > 0) return call.error(globalThis.lng.email_6);
call.succ(EmailFun.removeEmail(call.uid, call.req._id));
}