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(', ')}` );