diff --git a/web/controllers/chatNotificationController/index.ts b/web/controllers/chatNotificationController/index.ts index b7ffa479f..4c8c125c7 100644 --- a/web/controllers/chatNotificationController/index.ts +++ b/web/controllers/chatNotificationController/index.ts @@ -39,8 +39,9 @@ async function handleChatNotification(req: WithRawBody, res: Response): const chatType = getChatType(conversationParticipants); const isUserVerified = await verifyChatUser(recipientUser); + const onlySystemMessages = data.messages.every((m) => m.type === 'SystemMessage'); - if (isUserVerified) { + if (!onlySystemMessages && isUserVerified) { const notificationContext = await getNotificationContext(notificationBody); const notificationAction = chatType === ChatType.ONE_ON_ONE ? 'missed_one_on_one_chat_message' : 'missed_course_chat_message'; diff --git a/web/controllers/chatNotificationController/util.ts b/web/controllers/chatNotificationController/util.ts index e1afa7c2c..435bae284 100644 --- a/web/controllers/chatNotificationController/util.ts +++ b/web/controllers/chatNotificationController/util.ts @@ -45,10 +45,12 @@ export async function getNotificationContext(notificationBody: NotificationTrigg courseId = subcourse.courseId; } + const filteredMessages = messages.filter((message) => message.type !== 'SystemMessage'); + notificationContext = { sender: { firstname: firstnameSender }, conversationId: conversation.id, - message: messages[0].text, + message: filteredMessages[0].text, totalUnread: messages.length.toString(), ...(match ? { matchId: match.matchId } : {}), ...(courseId ? { courseId: courseId.toString() } : {}),