import express from 'express';
import { acknowledgeSystem } from '../../../../features/player/acknowledge';
import { LoginSystem } from '../../../../features/login';

export async function AccountAckMessage(req: express.Request, res: express.Response): Promise<void> {
    if (!req.body.accountId) {
        res.status(400).send('Missing parameter');
    }

    if (!Number(req.body.accountId)) {
        res.status(500).send('Unable to parse given parameter');
    }

    const player = mp.players.toArray().find((player) => player.account?.id === Number(req.body.accountId));

    if (player && LoginSystem.IsLoggedIn(player)) {
        acknowledgeSystem.showFirstMessage(player as PlayerMpLoggedIn).then();
    }

    res.sendStatus(200);
}
