From a0c41bce0aa12fca79a09b1d2ef2a37e1fdaca99 Mon Sep 17 00:00:00 2001 From: Maurice Date: Mon, 23 Nov 2026 15:44:24 +0100 Subject: [PATCH] fix(notifications): list the wanderer hints for users whose trip switched Tours on The user's matrix decides that row by the same per-user Tours rule the wanderer watch sends by, so a user who gets the hints can see and switch them. --- .../notification-preferences.service.ts | 2 +- server/tests/helpers/notifications.ts | 2 ++ .../notification-preferences.service.test.ts | 20 ++++++++++++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/server/src/nest/notifications/notification-preferences.service.ts b/server/src/nest/notifications/notification-preferences.service.ts index 5a3e71be9..2794e8071 100644 --- a/server/src/nest/notifications/notification-preferences.service.ts +++ b/server/src/nest/notifications/notification-preferences.service.ts @@ -139,7 +139,7 @@ export class NotificationPreferencesService { case 'synology_session_cleared': return photoProviders.includes('synologyphotos'); case 'wanderer_source_hint': - return this.addons.isWandererAvailable(); + return (await this.addons.isWandererAllowed()) && (await on(ADDON_IDS.TOURS)); case 'flight_departed': case 'flight_delayed': case 'flight_landed': diff --git a/server/tests/helpers/notifications.ts b/server/tests/helpers/notifications.ts index 7471ab9a0..4461d4279 100644 --- a/server/tests/helpers/notifications.ts +++ b/server/tests/helpers/notifications.ts @@ -115,6 +115,7 @@ export function everyFeatureOn( | 'isEnabledForUserAnywhere' | 'isEnabledAnywhere' | 'isWandererAvailable' + | 'isWandererAllowed' | 'enabledPhotoProviderIds' > > = {}, @@ -124,6 +125,7 @@ export function everyFeatureOn( isEnabledForUserAnywhere: async () => true, isEnabledAnywhere: async () => true, isWandererAvailable: async () => true, + isWandererAllowed: async () => true, enabledPhotoProviderIds: async () => ['immich', 'synologyphotos'], ...overrides, } as unknown as AddonsService; diff --git a/server/tests/unit/nest/notification-preferences.service.test.ts b/server/tests/unit/nest/notification-preferences.service.test.ts index fee7fb768..17328a7b2 100644 --- a/server/tests/unit/nest/notification-preferences.service.test.ts +++ b/server/tests/unit/nest/notification-preferences.service.test.ts @@ -461,7 +461,7 @@ describe('listed events follow the features that are on', () => { const all = { ...features }; Object.assign(features, { isAddonEnabled: async (id: string) => id !== 'vacay' && id !== 'collections', - isWandererAvailable: async () => false, + isWandererAllowed: async () => false, enabledPhotoProviderIds: async () => ['immich'], }); try { @@ -502,6 +502,24 @@ describe('listed events follow the features that are on', () => { } }); + it('NPREF-LIST-003b: the wanderer hints are listed for a user whose trip switched Tours on, as the watch sends them', async () => { + const { user: walker } = createUser(testDb); + const { user: quiet } = createUser(testDb); + const all = { ...features }; + Object.assign(features, { + isAddonEnabled: async (id: string) => id !== 'tours', + isEnabledForUserAnywhere: async (userId: number, id: string) => id === 'tours' && userId === walker.id, + }); + try { + expect((await svc.getPreferencesMatrix(walker.id, 'user')).event_types).toContain('wanderer_source_hint'); + expect((await svc.getPreferencesMatrix(quiet.id, 'user')).event_types).not.toContain('wanderer_source_hint'); + Object.assign(features, { isWandererAllowed: async () => false }); + expect((await svc.getPreferencesMatrix(walker.id, 'user')).event_types).not.toContain('wanderer_source_hint'); + } finally { + Object.assign(features, all); + } + }); + it('NPREF-LIST-004: the admin matrix lists the paddle region request while any trip has Tours on, not only on a trip of the admin', async () => { const { user: admin } = createAdmin(testDb); const all = { ...features };