chore: fix duplicate notification

This commit is contained in:
2024-12-16 18:01:15 +07:00
parent c4ed887727
commit b61e4dfc73

View File

@@ -420,8 +420,10 @@ export class ServiceSchema extends PothosSchema {
}) })
// get user ids from centerMentorIds // get user ids from centerMentorIds
const userIds = [center.centerOwnerId, ...mentorIds] const userIds = [center.centerOwnerId, ...mentorIds]
// remove duplicate user ids
const uniqueUserIds = [...new Set(userIds)]
// send notification to user using context // send notification to user using context
userIds.forEach(async (id) => { uniqueUserIds.forEach(async (id) => {
// add message to database // add message to database
const message = await this.prisma.message.create({ const message = await this.prisma.message.create({
data: { data: {
@@ -447,7 +449,9 @@ export class ServiceSchema extends PothosSchema {
// send notification to user using context // send notification to user using context
// get user ids from mentorIds // get user ids from mentorIds
const userIds = [center.centerOwnerId, ...mentorIds] const userIds = [center.centerOwnerId, ...mentorIds]
userIds.forEach(async (id) => { // remove duplicate user ids
const uniqueUserIds = [...new Set(userIds)]
uniqueUserIds.forEach(async (id) => {
// add message to database // add message to database
const message = await this.prisma.message.create({ const message = await this.prisma.message.create({
data: { data: {