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

@@ -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);
}
/**