This commit is contained in:
2025-12-11 11:25:22 +01:00
parent 6a427eab57
commit e4c1be628d
86 changed files with 1222 additions and 736 deletions

View File

@@ -5,6 +5,7 @@
*/
import type { INotificationRepository } from '../../domain/repositories/INotificationRepository';
import { NotificationDomainError } from '../../domain/errors/NotificationDomainError';
export interface MarkNotificationReadCommand {
notificationId: string;
@@ -20,11 +21,11 @@ export class MarkNotificationReadUseCase {
const notification = await this.notificationRepository.findById(command.notificationId);
if (!notification) {
throw new Error('Notification not found');
throw new NotificationDomainError('Notification not found');
}
if (notification.recipientId !== command.recipientId) {
throw new Error('Cannot mark another user\'s notification as read');
throw new NotificationDomainError('Cannot mark another user\'s notification as read');
}
if (!notification.isUnread()) {
@@ -70,11 +71,11 @@ export class DismissNotificationUseCase {
const notification = await this.notificationRepository.findById(command.notificationId);
if (!notification) {
throw new Error('Notification not found');
throw new NotificationDomainError('Notification not found');
}
if (notification.recipientId !== command.recipientId) {
throw new Error('Cannot dismiss another user\'s notification');
throw new NotificationDomainError('Cannot dismiss another user\'s notification');
}
if (notification.isDismissed()) {