wip
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
* Immutable entity with factory methods and domain validation.
|
||||
*/
|
||||
|
||||
import { NotificationDomainError } from '../errors/NotificationDomainError';
|
||||
|
||||
import type { NotificationType } from '../value-objects/NotificationType';
|
||||
import type { NotificationChannel } from '../value-objects/NotificationChannel';
|
||||
|
||||
@@ -91,12 +93,12 @@ export class Notification {
|
||||
createdAt?: Date;
|
||||
urgency?: NotificationUrgency;
|
||||
}): Notification {
|
||||
if (!props.id) throw new Error('Notification ID is required');
|
||||
if (!props.recipientId) throw new Error('Recipient ID is required');
|
||||
if (!props.type) throw new Error('Notification type is required');
|
||||
if (!props.title?.trim()) throw new Error('Notification title is required');
|
||||
if (!props.body?.trim()) throw new Error('Notification body is required');
|
||||
if (!props.channel) throw new Error('Notification channel is required');
|
||||
if (!props.id) throw new NotificationDomainError('Notification ID is required');
|
||||
if (!props.recipientId) throw new NotificationDomainError('Recipient ID is required');
|
||||
if (!props.type) throw new NotificationDomainError('Notification type is required');
|
||||
if (!props.title?.trim()) throw new NotificationDomainError('Notification title is required');
|
||||
if (!props.body?.trim()) throw new NotificationDomainError('Notification body is required');
|
||||
if (!props.channel) throw new NotificationDomainError('Notification channel is required');
|
||||
|
||||
// Modal notifications that require response start with action_required status
|
||||
const defaultStatus = props.requiresResponse ? 'action_required' : 'unread';
|
||||
@@ -196,7 +198,7 @@ export class Notification {
|
||||
}
|
||||
// Cannot dismiss action_required notifications without responding
|
||||
if (this.props.requiresResponse && this.props.status === 'action_required') {
|
||||
throw new Error('Cannot dismiss notification that requires response');
|
||||
throw new NotificationDomainError('Cannot dismiss notification that requires response');
|
||||
}
|
||||
return new Notification({
|
||||
...this.props,
|
||||
|
||||
Reference in New Issue
Block a user