add a flag to control whether the notification service should actually send notifications

This commit is contained in:
2025-02-19 11:14:48 -08:00
parent 92537a298b
commit f1b9fb6824

View File

@@ -27,7 +27,7 @@ export class NotificationService {
return this._lastRefreshedTimeMs; return this._lastRefreshedTimeMs;
} }
constructor(private repository: GetterRepository) { constructor(private repository: GetterRepository, private shouldActuallySendNotifications = true) {
this.etaSubscriberCallback = this.etaSubscriberCallback.bind(this); this.etaSubscriberCallback = this.etaSubscriberCallback.bind(this);
this.reloadAPNsTokenIfTimePassed = this.reloadAPNsTokenIfTimePassed.bind(this); this.reloadAPNsTokenIfTimePassed = this.reloadAPNsTokenIfTimePassed.bind(this);
this.lastReloadedTimeForAPNsIsTooRecent = this.lastReloadedTimeForAPNsIsTooRecent.bind(this); this.lastReloadedTimeForAPNsIsTooRecent = this.lastReloadedTimeForAPNsIsTooRecent.bind(this);
@@ -81,6 +81,10 @@ export class NotificationService {
} }
private async sendEtaNotificationImmediately(notificationData: ScheduledNotificationData): Promise<boolean> { private async sendEtaNotificationImmediately(notificationData: ScheduledNotificationData): Promise<boolean> {
if (!this.shouldActuallySendNotifications) {
return true; // pretend that the notification sent
}
const { deviceId, shuttleId, stopId } = notificationData; const { deviceId, shuttleId, stopId } = notificationData;
this.reloadAPNsTokenIfTimePassed(); this.reloadAPNsTokenIfTimePassed();