This commit is contained in:
2025-12-11 21:06:25 +01:00
parent c49ea2598d
commit ec3ddc3a5c
227 changed files with 3496 additions and 2083 deletions

View File

@@ -64,9 +64,9 @@ export class SendNotificationUseCase implements AsyncUseCase<SendNotificationCom
title: command.title,
body: command.body,
channel: 'in_app',
data: command.data,
actionUrl: command.actionUrl,
status: 'dismissed', // Auto-dismiss since user doesn't want these
...(command.data ? { data: command.data } : {}),
...(command.actionUrl ? { actionUrl: command.actionUrl } : {}),
});
await this.notificationRepository.create(notification);
@@ -102,11 +102,13 @@ export class SendNotificationUseCase implements AsyncUseCase<SendNotificationCom
title: command.title,
body: command.body,
channel,
urgency: command.urgency,
data: command.data,
actionUrl: command.actionUrl,
actions: command.actions,
requiresResponse: command.requiresResponse,
...(command.urgency ? { urgency: command.urgency } : {}),
...(command.data ? { data: command.data } : {}),
...(command.actionUrl ? { actionUrl: command.actionUrl } : {}),
...(command.actions ? { actions: command.actions } : {}),
...(command.requiresResponse !== undefined
? { requiresResponse: command.requiresResponse }
: {}),
});
// Save to repository (in_app channel) or attempt delivery (external channels)

View File

@@ -184,12 +184,17 @@ export class Notification implements IEntity<string> {
* Mark that the user has responded to an action_required notification
*/
markAsResponded(actionId?: string): Notification {
const data =
actionId !== undefined
? { ...(this.props.data ?? {}), responseActionId: actionId }
: this.props.data;
return new Notification({
...this.props,
status: 'read',
readAt: this.props.readAt ?? new Date(),
respondedAt: new Date(),
data: actionId ? { ...this.props.data, responseActionId: actionId } : this.props.data,
...(data !== undefined ? { data } : {}),
});
}

View File

@@ -172,26 +172,32 @@ export class NotificationPreference implements IEntity<string> {
* Update quiet hours
*/
updateQuietHours(start: number | undefined, end: number | undefined): NotificationPreference {
const validated = start === undefined || end === undefined ? undefined : QuietHours.create(start, end);
const props = this.toJSON();
return new NotificationPreference({
...this.props,
quietHoursStart: validated?.props.startHour,
quietHoursEnd: validated?.props.endHour,
updatedAt: new Date(),
});
if (start === undefined || end === undefined) {
delete props.quietHoursStart;
delete props.quietHoursEnd;
} else {
const validated = QuietHours.create(start, end);
props.quietHoursStart = validated.props.startHour;
props.quietHoursEnd = validated.props.endHour;
}
props.updatedAt = new Date();
return NotificationPreference.create(props);
}
/**
* Toggle digest mode
*/
setDigestMode(enabled: boolean, frequencyHours?: number): NotificationPreference {
return new NotificationPreference({
...this.props,
digestMode: enabled,
digestFrequencyHours: frequencyHours ?? this.props.digestFrequencyHours,
updatedAt: new Date(),
});
const props = this.toJSON();
props.digestMode = enabled;
if (frequencyHours !== undefined) {
props.digestFrequencyHours = frequencyHours;
}
props.updatedAt = new Date();
return NotificationPreference.create(props);
}
/**