mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-23 21:33:19 +00:00
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:
@@ -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':
|
||||
|
||||
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user