HJ_Server/src/api_s2c/email/ApiAllRemove.ts
xcy e49861bcaf fix:
修复邮件
2023-12-23 00:46:08 +08:00

14 lines
657 B
TypeScript

import { ApiCall } from "tsrpc";
import { EmailFun } from '../../public/email';
import { ReqAllRemove, ResAllRemove } from "../../shared/protocols/email/PtlAllRemove";
export default async function (call: ApiCall<ReqAllRemove, ResAllRemove>) {
// 筛选出没有奖励已读邮件和已经领取过奖励的邮件
let emailList = (await EmailFun.getAllEmail(call.uid, true)).filter(email => (
(email.emailRead && email.prizeData?.prize.length <= 0) || email.prizeData.isGet
));
if (emailList.length < 1) return call.error(globalThis.lng.email_2);
call.succ(EmailFun.removeEmail(call.uid, emailList.map(email => email._id)));
}