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.
This commit is contained in:
Maurice
2026-11-23 15:44:24 +01:00
parent 1a6639eb74
commit a0c41bce0a
3 changed files with 22 additions and 2 deletions
@@ -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':
+2
View File
@@ -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;
@@ -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 };