diff --git a/apps/backend/src/application/controllers/notifications.controller.ts b/apps/backend/src/application/controllers/notifications.controller.ts index e66a090..1a3b06f 100644 --- a/apps/backend/src/application/controllers/notifications.controller.ts +++ b/apps/backend/src/application/controllers/notifications.controller.ts @@ -22,6 +22,7 @@ import { NotificationService } from '../services/notification.service'; import { JwtAuthGuard } from '../guards/jwt-auth.guard'; import { CurrentUser, UserPayload } from '../decorators/current-user.decorator'; import { Notification } from '@domain/entities/notification.entity'; +import { notificationTarget } from '@domain/services/notification-target'; class NotificationResponseDto { id: string; @@ -200,7 +201,12 @@ export class NotificationsController { metadata: notification.metadata, read: notification.read, readAt: notification.readAt?.toISOString(), - actionUrl: notification.actionUrl, + // La destination est derivee du type et des metadonnees : les liens + // ecrits a la main visaient des routes inexistantes. + actionUrl: + notification.actionUrl ?? + notificationTarget(notification.type, notification.metadata) ?? + undefined, createdAt: notification.createdAt.toISOString(), }; } diff --git a/apps/backend/src/application/controllers/organizations.controller.ts b/apps/backend/src/application/controllers/organizations.controller.ts index bb272d4..d19b8ae 100644 --- a/apps/backend/src/application/controllers/organizations.controller.ts +++ b/apps/backend/src/application/controllers/organizations.controller.ts @@ -356,7 +356,6 @@ export class OrganizationsController { siren: organization.siren, requestedBy: user.email, }, - actionUrl: `/dashboard/admin/organizations`, }) ) ); diff --git a/apps/backend/src/application/gateways/notifications.gateway.ts b/apps/backend/src/application/gateways/notifications.gateway.ts index 0e52814..739aace 100644 --- a/apps/backend/src/application/gateways/notifications.gateway.ts +++ b/apps/backend/src/application/gateways/notifications.gateway.ts @@ -18,6 +18,7 @@ import { Logger, UseGuards } from '@nestjs/common'; import { JwtService } from '@nestjs/jwt'; import { NotificationService } from '../services/notification.service'; import { Notification } from '@domain/entities/notification.entity'; +import { notificationTarget } from '@domain/services/notification-target'; /** * WebSocket authentication guard @@ -236,7 +237,10 @@ export class NotificationsGateway implements OnGatewayConnection, OnGatewayDisco metadata: notification.metadata, read: notification.read, readAt: notification.readAt?.toISOString(), - actionUrl: notification.actionUrl, + actionUrl: + notification.actionUrl ?? + notificationTarget(notification.type, notification.metadata) ?? + undefined, createdAt: notification.createdAt.toISOString(), }; } diff --git a/apps/backend/src/application/services/notification.service.ts b/apps/backend/src/application/services/notification.service.ts index 9ee4c23..2deac6a 100644 --- a/apps/backend/src/application/services/notification.service.ts +++ b/apps/backend/src/application/services/notification.service.ts @@ -157,7 +157,6 @@ export class NotificationService { title: 'Booking Created', message: `Your booking ${bookingNumber} has been created successfully.`, metadata: { bookingId, bookingNumber }, - actionUrl: `/bookings/${bookingId}`, }); } @@ -176,7 +175,6 @@ export class NotificationService { title: 'Booking Updated', message: `Booking ${bookingNumber} status changed to ${status}.`, metadata: { bookingId, bookingNumber, status }, - actionUrl: `/bookings/${bookingId}`, }); } @@ -194,7 +192,6 @@ export class NotificationService { title: 'Booking Confirmed', message: `Your booking ${bookingNumber} has been confirmed by the carrier.`, metadata: { bookingId, bookingNumber }, - actionUrl: `/bookings/${bookingId}`, }); } @@ -212,7 +209,6 @@ export class NotificationService { title: 'Document Uploaded', message: `Document "${documentName}" has been uploaded for your booking.`, metadata: { documentName, bookingId }, - actionUrl: `/bookings/${bookingId}`, }); } }