collect-system/apps/server/src/models/message/utils.ts

20 lines
441 B
TypeScript
Executable File

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
})
}