wip
This commit is contained in:
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user