2025-01-06 08:45:23 +08:00
|
|
|
import { Message, UserProfile, VisitType, db } from "@nice/common"
|
2024-12-30 08:26:40 +08:00
|
|
|
export async function setMessageRelation(
|
|
|
|
data: Message,
|
|
|
|
staff?: UserProfile,
|
|
|
|
): Promise<any> {
|
|
|
|
|
|
|
|
const readed =
|
|
|
|
(await db.visit.count({
|
|
|
|
where: {
|
|
|
|
messageId: data.id,
|
2024-12-31 15:57:32 +08:00
|
|
|
type: VisitType.READED,
|
2024-12-30 08:26:40 +08:00
|
|
|
visitorId: staff?.id,
|
|
|
|
},
|
|
|
|
})) > 0;
|
|
|
|
|
|
|
|
|
|
|
|
Object.assign(data, {
|
|
|
|
readed
|
|
|
|
})
|
|
|
|
}
|