From a665c29745567509ec108cedfaf9c40792eb885f Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Thu, 27 Mar 2025 10:46:38 -0700 Subject: [PATCH] add method to check if notification is scheduled --- src/repositories/InMemoryNotificationRepository.ts | 5 +++++ src/repositories/NotificationRepository.ts | 1 + 2 files changed, 6 insertions(+) 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; }