add method to check if notification is scheduled

This commit is contained in:
2025-03-27 10:46:38 -07:00
parent 3761f43909
commit a665c29745
2 changed files with 6 additions and 0 deletions

View File

@@ -42,6 +42,10 @@ export class InMemoryNotificationRepository implements NotificationRepository {
return this.deviceIdsToDeliverTo[tuple.toString()][deviceId];
}
async isNotificationScheduled(lookupArguments: NotificationLookupArguments): Promise<boolean> {
return await this.getSecondsThresholdForNotificationIfExists(lookupArguments) !== null;
}
async addOrUpdateNotification({
shuttleId,
stopId,
@@ -71,4 +75,5 @@ export class InMemoryNotificationRepository implements NotificationRepository {
delete this.deviceIdsToDeliverTo[tupleKey.toString()][deviceId];
}
}

View File

@@ -17,6 +17,7 @@ export interface ScheduledNotification extends NotificationLookupArguments {
export interface NotificationRepository {
getAllNotificationsForShuttleAndStopId(shuttleId: string, stopId: string): Promise<ScheduledNotification[]>;
getSecondsThresholdForNotificationIfExists(lookupArguments: NotificationLookupArguments): Promise<number | null>;
isNotificationScheduled(lookupArguments: NotificationLookupArguments): Promise<boolean>;
addOrUpdateNotification(notification: ScheduledNotification): Promise<void>;
deleteNotificationIfExists(lookupArguments: NotificationLookupArguments): Promise<void>;
}