diff --git a/src/repositories/InMemoryNotificationRepository.ts b/src/repositories/InMemoryNotificationRepository.ts index db6e9bc..ecd3e7b 100644 --- a/src/repositories/InMemoryNotificationRepository.ts +++ b/src/repositories/InMemoryNotificationRepository.ts @@ -42,6 +42,10 @@ export class InMemoryNotificationRepository implements NotificationRepository { return this.deviceIdsToDeliverTo[tuple.toString()][deviceId]; } + async isNotificationScheduled(lookupArguments: NotificationLookupArguments): Promise { + 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]; } + } diff --git a/src/repositories/NotificationRepository.ts b/src/repositories/NotificationRepository.ts index 343497e..6914bf8 100644 --- a/src/repositories/NotificationRepository.ts +++ b/src/repositories/NotificationRepository.ts @@ -17,6 +17,7 @@ export interface ScheduledNotification extends NotificationLookupArguments { export interface NotificationRepository { getAllNotificationsForShuttleAndStopId(shuttleId: string, stopId: string): Promise; getSecondsThresholdForNotificationIfExists(lookupArguments: NotificationLookupArguments): Promise; + isNotificationScheduled(lookupArguments: NotificationLookupArguments): Promise; addOrUpdateNotification(notification: ScheduledNotification): Promise; deleteNotificationIfExists(lookupArguments: NotificationLookupArguments): Promise; }