import {ApiCall} from "tsrpc";
import {ReqGetCrossEmail, ResGetCrossEmail} from "../../cross/protocols/email/PtlGetCrossEmail";


export default async function (call: ApiCall<ReqGetCrossEmail, ResGetCrossEmail>) {
    let emails = await G.mongodb.collection("email").find(
        {sid: call.req.server_id, isdel: {$exists: false}},
        {projection: {isdel: 0}}
    ).toArray()

    call.succ({
        emails: emails.map((e) => {
            return {...e, _id: G.mongodb.conversionId(e._id)}
        })
    })
}