import { ApiCall } from "tsrpc";
import { FriendManage } from '../../public/friend/manage';
import { ReqDel, ResDel } from "../../shared/protocols/friend/PtlDel";

export default async function (call: ApiCall<ReqDel, ResDel>) {
    const my = await FriendManage.getFriend(call.uid);

    if (!my.data.friendList.includes(call.req.uid)) return call.error(globalThis.lng.friend_8);

    my.delFriend(call.req.uid);

    const he = await FriendManage.getFriend(call.req.uid);

    he?.delFriend(call.uid);

    call.succ({});
}