import { Message, UserProfile, VisitType, db } from "@nice/common"
export async function setMessageRelation(
    data: Message,
    staff?: UserProfile,
): Promise<any> {

    const readed =
        (await db.visit.count({
            where: {
                messageId: data.id,
                type: VisitType.READED,
                visitorId: staff?.id,
            },
        })) > 0;


    Object.assign(data, {
        readed
    })
}