From b61e4dfc7388544e41a24e1295fdbefd3569a386 Mon Sep 17 00:00:00 2001 From: Ly Tuan Kiet Date: Mon, 16 Dec 2024 18:01:15 +0700 Subject: [PATCH] chore: fix duplicate notification --- src/Service/service.schema.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Service/service.schema.ts b/src/Service/service.schema.ts index d91242b..3558ceb 100644 --- a/src/Service/service.schema.ts +++ b/src/Service/service.schema.ts @@ -420,8 +420,10 @@ export class ServiceSchema extends PothosSchema { }) // get user ids from centerMentorIds const userIds = [center.centerOwnerId, ...mentorIds] + // remove duplicate user ids + const uniqueUserIds = [...new Set(userIds)] // send notification to user using context - userIds.forEach(async (id) => { + uniqueUserIds.forEach(async (id) => { // add message to database const message = await this.prisma.message.create({ data: { @@ -447,7 +449,9 @@ export class ServiceSchema extends PothosSchema { // send notification to user using context // get user ids from 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 const message = await this.prisma.message.create({ data: {