Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(notifications): list the wanderer hints for users whose trip switched Tours on

Mauricea0c41bce0aa1
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 };