From 6068c34c3500e076793aa81961586dceb54e815d Mon Sep 17 00:00:00 2001 From: Maurice Date: Sun, 29 Nov 2026 00:21:10 +0100 Subject: [PATCH] fix(atlas): keep auth.service at its size, finish the last ratchets - The public config's feature switches, the Atlas comparison among them, move into a helper, so auth.service shrinks instead of growing past its size baseline (lowered to the new length). - French "continents" in the many form is the French word too. - useAtlasCountryActions no longer imports the API: off the offline list. - The eslint baseline follows two lower counts. --- client/scripts/eslint-baseline.json | 4 ++-- client/scripts/offline-baseline.json | 1 - server/scripts/size-baseline.json | 2 +- server/src/nest/auth/auth.helpers.ts | 19 +++++++++++++++++++ server/src/nest/auth/auth.service.ts | 18 ++---------------- shared/src/i18n/fr/atlas.ts | 2 +- 6 files changed, 25 insertions(+), 21 deletions(-) diff --git a/client/scripts/eslint-baseline.json b/client/scripts/eslint-baseline.json index c5a5176b1..54b332ecf 100644 --- a/client/scripts/eslint-baseline.json +++ b/client/scripts/eslint-baseline.json @@ -11,8 +11,8 @@ "react-hooks/refs": 522, "react-hooks/set-state-in-effect": 188, "@typescript-eslint/no-floating-promises": 162, - "react-hooks/exhaustive-deps": 113, - "@typescript-eslint/no-unused-vars": 101, + "react-hooks/exhaustive-deps": 112, + "@typescript-eslint/no-unused-vars": 100, "react-hooks/immutability": 26, "max-lines-per-function": 126, "react-hooks/static-components": 38, diff --git a/client/scripts/offline-baseline.json b/client/scripts/offline-baseline.json index 5f90144dd..fbff7cf37 100644 --- a/client/scripts/offline-baseline.json +++ b/client/scripts/offline-baseline.json @@ -129,7 +129,6 @@ "src/pages/OAuthAuthorizePage.tsx", "src/pages/admin/useAdmin.ts", "src/pages/admin/useNotificationDefaults.ts", - "src/pages/atlas/useAtlasCountryActions.ts", "src/pages/collections/useCollections.ts", "src/pages/dashboard/useDashboard.ts", "src/pages/dashboard/useTripSearch.ts", diff --git a/server/scripts/size-baseline.json b/server/scripts/size-baseline.json index 5277b10a0..ad3ee5073 100644 --- a/server/scripts/size-baseline.json +++ b/server/scripts/size-baseline.json @@ -6,7 +6,7 @@ "src/db/repositories/Trips.repository.ts": 1120, "src/db/repositories/Users.repository.ts": 1421, "src/nest/atlas/atlas.service.ts": 1166, - "src/nest/auth/auth.service.ts": 1126, + "src/nest/auth/auth.service.ts": 1115, "src/nest/budget/budget.service.ts": 1607, "src/nest/collections/collections.service.ts": 1414, "src/nest/doc-sync/doc-sync.service.ts": 1060, diff --git a/server/src/nest/auth/auth.helpers.ts b/server/src/nest/auth/auth.helpers.ts index cd8515dc7..83e5a3aee 100644 --- a/server/src/nest/auth/auth.helpers.ts +++ b/server/src/nest/auth/auth.helpers.ts @@ -162,3 +162,22 @@ export function appSettingsAudit( ); return { summary, debugDetails }; } + +/** + * The feature switches of the public app config, read from the instance settings + * in the order the response has always listed them. + */ +export function publicFeatureFlags(settings: Map) { + return { + places_photos_enabled: settings.get('places_photos_enabled') !== 'false', + places_autocomplete_enabled: settings.get('places_autocomplete_enabled') !== 'false', + places_details_enabled: settings.get('places_details_enabled') !== 'false', + places_enrich_enabled: settings.get('places_enrich_enabled') !== 'false', + // Fail-closed, and deliberately on this unauthenticated endpoint: whether an + // instance records what its users search for is something a visitor is + // entitled to know before logging in, not a detail to keep behind the door. + place_shadow_enabled: settings.get('place_shadow_enabled') === 'true', + // The Atlas comparison of travellers; on until an admin stores 'false'. + atlas_compare_enabled: settings.get('atlas_compare_enabled') !== 'false', + }; +} diff --git a/server/src/nest/auth/auth.service.ts b/server/src/nest/auth/auth.service.ts index 31db3047d..bd045b2a4 100644 --- a/server/src/nest/auth/auth.service.ts +++ b/server/src/nest/auth/auth.service.ts @@ -70,6 +70,7 @@ import { parseBackupCodeHashes, stripUserForClient, appSettingsAudit, + publicFeatureFlags, } from './auth.helpers'; import { ADMIN_FORM_SETTING_KEYS, @@ -330,16 +331,6 @@ export class AuthService { const hasWebhookEnabled = activeChannels.includes('webhook'); const hasPushEnabled = activeChannels.includes(WEB_PUSH_CHANNEL_ID); const tripRemindersEnabled = tripReminderSetting !== 'false'; - const placesPhotosEnabled = settings.get('places_photos_enabled') !== 'false'; - const placesAutocompleteEnabled = settings.get('places_autocomplete_enabled') !== 'false'; - const placesDetailsEnabled = settings.get('places_details_enabled') !== 'false'; - const placesEnrichEnabled = settings.get('places_enrich_enabled') !== 'false'; - // Fail-closed, and deliberately on this unauthenticated endpoint: whether an - // instance records what its users search for is something a visitor is - // entitled to know before logging in, not a detail to keep behind the door. - const placeShadowEnabled = settings.get('place_shadow_enabled') === 'true'; - // The Atlas comparison of travellers; on until an admin stores 'false'. - const atlasCompareEnabled = settings.get('atlas_compare_enabled') !== 'false'; const setupComplete = userCount > 0 && (await this.usersRepo.findAdminNeedingPasswordChange()) === null; return { @@ -389,12 +380,7 @@ export class AuthService { notification_channels: activeChannels, available_channels: { email: hasSmtpHost, webhook: hasWebhookEnabled, push: hasPushEnabled, inapp: true }, trip_reminders_enabled: tripRemindersEnabled, - places_photos_enabled: placesPhotosEnabled, - places_autocomplete_enabled: placesAutocompleteEnabled, - places_details_enabled: placesDetailsEnabled, - places_enrich_enabled: placesEnrichEnabled, - place_shadow_enabled: placeShadowEnabled, - atlas_compare_enabled: atlasCompareEnabled, + ...publicFeatureFlags(settings), permissions: authenticatedUser ? (await this.permissions.getAllPermissions()) : undefined, // Case-sensitive on purpose (legacy parity). dev_mode: readEnv().app.nodeEnv === 'development', diff --git a/shared/src/i18n/fr/atlas.ts b/shared/src/i18n/fr/atlas.ts index 1ed5ea100..296922959 100644 --- a/shared/src/i18n/fr/atlas.ts +++ b/shared/src/i18n/fr/atlas.ts @@ -119,7 +119,7 @@ const atlas: TranslationStrings = { 'atlas.badge.continentsDesc': 'Visitez les six continents habités.', 'atlas.badge.continentsN': '{count} continents', // same-as-en 'atlas.badge.continentsN.one': '{count} continent', // same-as-en - 'atlas.badge.continentsN.many': '{count} continents', + 'atlas.badge.continentsN.many': '{count} continents', // same-as-en 'atlas.badge.continentsNDesc': 'Posez le pied sur {count} continents.', 'atlas.badge.continentsNDesc.one': 'Posez le pied sur {count} continent.', 'atlas.badge.continentsNDesc.many': 'Posez le pied sur {count} continents.',