import {ApiCall} from "tsrpc";
import {EmailFun} from '../../public/email';
import {ReqOpen, ResOpen} from "../../shared/protocols/email/PtlOpen";

export default async function (call: ApiCall<ReqOpen, ResOpen>) {
    // 存入当前玩家多语言信息
    await G.redis.rawSet(`user:lng:${call.uid}`, call.req.lng, {EX: 259200})

    let list = await EmailFun.getAllEmail(call.uid, false);
    let obj: ResOpen = {};
    for (let email of list) {
        obj[email._id] = email;
        if (email.prizelist) delete email.prizelist;
    }

    call.succ(obj);
}