feat: integrate reminder payloads into appointment creation and update notification jobs and adjust quiet hours logic
This commit is contained in:
@@ -16,6 +16,7 @@ export interface CreateJobServiceParams {
|
||||
scheduledAt?: Date;
|
||||
appointmentStart?: Date;
|
||||
payload?: CreateJobParams["payload"];
|
||||
reminderPayload?: CreateJobParams["payload"];
|
||||
}
|
||||
|
||||
export class NotificationJobService {
|
||||
@@ -81,6 +82,7 @@ export class NotificationJobService {
|
||||
channel,
|
||||
type: "reminder",
|
||||
scheduledAt: reminderScheduledAt,
|
||||
payload: params.reminderPayload,
|
||||
});
|
||||
jobs.push(job);
|
||||
}
|
||||
@@ -153,12 +155,9 @@ export class NotificationJobService {
|
||||
if (isInsideQuietHours) {
|
||||
// Shift to quiet hours end
|
||||
let adjusted = scheduled.hour(toHour).minute(toMinute).second(0);
|
||||
// If quiet hours cross midnight (e.g. 22:00-07:00) and end is before start,
|
||||
// the end is on the next day
|
||||
if (toHour < fromHour) {
|
||||
if (scheduledHour >= fromHour || scheduledHour < toHour) {
|
||||
adjusted = adjusted.add(1, "day");
|
||||
}
|
||||
// If quiet hours cross midnight, only the pre-midnight segment ends next day.
|
||||
if (toHour < fromHour && scheduledHour >= fromHour) {
|
||||
adjusted = adjusted.add(1, "day");
|
||||
}
|
||||
return adjusted.toDate();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user