feat(api): servir la destination et le compteur de non-lues

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018BAUeCFpDkRD6tU5wGsc1C
This commit is contained in:
David 2026-09-07 21:40:56 +02:00
parent 33d70a16dd
commit f67de177e8
4 changed files with 12 additions and 7 deletions

View File

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

View File

@ -356,7 +356,6 @@ export class OrganizationsController {
siren: organization.siren,
requestedBy: user.email,
},
actionUrl: `/dashboard/admin/organizations`,
})
)
);

View File

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

View File

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