14 lines
657 B
TypeScript
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)));
|
|
} |