From 2ab9554c0cd6ced4561d54a53ec6ff75b7973cfc Mon Sep 17 00:00:00 2001 From: Abdalhamid Alhamad Date: Sun, 1 Feb 2026 14:44:42 +0300 Subject: [PATCH] feat: add profile update notification handling for child users - Implemented logic to skip notifications for child users (roles.JUNIOR) when their profiles are updated, preventing unnecessary notifications to both child and parent. - Enhanced logging to indicate when notifications are skipped for child users. --- .../listeners/profile-notification.listener.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/common/modules/notification/listeners/profile-notification.listener.ts b/src/common/modules/notification/listeners/profile-notification.listener.ts index ea65b8a..7abd825 100644 --- a/src/common/modules/notification/listeners/profile-notification.listener.ts +++ b/src/common/modules/notification/listeners/profile-notification.listener.ts @@ -1,6 +1,7 @@ import { Injectable, Logger } from '@nestjs/common'; import { OnEvent } from '@nestjs/event-emitter'; import { I18nService } from 'nestjs-i18n'; +import { Roles } from '~/auth/enums'; import { NotificationFactory, NotificationPreferences } from '../services/notification-factory.service'; import { UserService } from '~/user/services/user.service'; import { NOTIFICATION_EVENTS } from '../constants/event-names.constant'; @@ -24,6 +25,14 @@ export class ProfileNotificationListener { try { const { user, updatedFields } = event; + // Do not notify when a child updates their profile (no notification to child or parent) + if (user?.roles?.includes(Roles.JUNIOR)) { + this.logger.log( + `Skipping profile updated notification for child user ${user.id} - no notification sent` + ); + return; + } + this.logger.log( `Processing profile updated notification for user ${user.id} - Updated fields: ${updatedFields.join(', ')}` );