diff --git a/server/scripts/import-boundaries-baseline.json b/server/scripts/import-boundaries-baseline.json index f6b681f13..208d067f9 100644 --- a/server/scripts/import-boundaries-baseline.json +++ b/server/scripts/import-boundaries-baseline.json @@ -35,7 +35,6 @@ "admin -> llm-parse/llm-config.ts", "atlas -> geo/nominatim.client.ts", "atlas -> public-api/public-api-request.ts", - "auth -> maps/maps.helpers.ts", "auth -> maps/providers/places-provider.ts", "auth -> plugins/paths.ts", "auth -> plugins/user-erasure-enqueue.ts", diff --git a/server/src/nest/auth/user-profile.service.ts b/server/src/nest/auth/user-profile.service.ts index 44d7df990..034b63803 100644 --- a/server/src/nest/auth/user-profile.service.ts +++ b/server/src/nest/auth/user-profile.service.ts @@ -15,7 +15,7 @@ import { writeInstanceApiKey, type InstanceApiKeyName, } from '../settings/instance-api-keys'; -import { SEARCH_TEXT_FIELD_MASK } from '../maps/maps.helpers'; +import { SEARCH_TEXT_FIELD_MASK } from '../maps/providers/google-places.constants'; import { AppSettings } from '../../db/entities/AppSettings.entity'; import type { AppSettingsRepository } from '../../db/repositories/AppSettings.repository'; import { Users } from '../../db/entities/Users.entity'; diff --git a/server/src/nest/maps/maps.helpers.ts b/server/src/nest/maps/maps.helpers.ts index 1e61a4889..c1f4dc09e 100644 --- a/server/src/nest/maps/maps.helpers.ts +++ b/server/src/nest/maps/maps.helpers.ts @@ -26,17 +26,6 @@ export function buildUserAgent(instanceUrl: string | undefined): string { // Computed once at load — getAppUrl() reads only env vars, which don't change at runtime. export const UA = buildUserAgent(getAppUrl()); -/** - * The fields places:searchText is asked for. - * - * Here rather than beside the call because the admin panel's key test has to - * send the same mask: a key restricted to a narrower set of Places SKUs answers - * a one-field probe with 200 and the real search with 403, which is the second - * way to reach the #1939 report ("test button green, searching fails"). - */ -export const SEARCH_TEXT_FIELD_MASK = - 'places.id,places.displayName,places.formattedAddress,places.location,places.rating,places.websiteUri,places.nationalPhoneNumber,places.types,places.googleMapsUri,places.businessStatus'; - // TREK's internal language codes mostly coincide with valid BCP-47 codes, but a // couple don't: 'br' is Brazilian Portuguese here (BCP-47 'pt-BR'; bare 'br' is // Breton) and 'gr' is Greek (BCP-47 'el'). Outbound geo APIs (Google Places, diff --git a/server/src/nest/maps/maps.service.ts b/server/src/nest/maps/maps.service.ts index c01dcfe50..708b5e5f2 100644 --- a/server/src/nest/maps/maps.service.ts +++ b/server/src/nest/maps/maps.service.ts @@ -23,6 +23,7 @@ import type { PlaceDetailsCacheRepository } from '../../db/repositories/PlaceDet import { Places } from '../../db/entities/Places.entity'; import type { PlacesRepository } from '../../db/repositories/Places.repository'; import { isPlacesProviderChoice, type PlacesProviderChoice } from './providers/places-provider'; +import { SEARCH_TEXT_FIELD_MASK } from './providers/google-places.constants'; import { AMAP_SHORT_HOSTS, AmapPlacesProvider, @@ -49,7 +50,6 @@ import { } from './trek-places.client'; import { UA, - SEARCH_TEXT_FIELD_MASK, toApiLang, googleFtidFromMapsUrl, buildOsmDetails, diff --git a/server/src/nest/maps/providers/google-places.constants.ts b/server/src/nest/maps/providers/google-places.constants.ts new file mode 100644 index 000000000..30d0104b8 --- /dev/null +++ b/server/src/nest/maps/providers/google-places.constants.ts @@ -0,0 +1,11 @@ +/** + * The fields places:searchText is asked for. + * + * Beside the Google places provider that sends them, and in a constants file + * because the admin panel's key test (auth/user-profile.service.ts) has to send + * the same mask: a key restricted to a narrower set of Places SKUs answers a + * one-field probe with 200 and the real search with 403, which is the second + * way to reach the #1939 report ("test button green, searching fails"). + */ +export const SEARCH_TEXT_FIELD_MASK = + 'places.id,places.displayName,places.formattedAddress,places.location,places.rating,places.websiteUri,places.nationalPhoneNumber,places.types,places.googleMapsUri,places.businessStatus'; diff --git a/server/tests/unit/nest/user-profile.service.test.ts b/server/tests/unit/nest/user-profile.service.test.ts index b9190eb1f..04f80f3f2 100644 --- a/server/tests/unit/nest/user-profile.service.test.ts +++ b/server/tests/unit/nest/user-profile.service.test.ts @@ -53,7 +53,7 @@ async function setUserColumns( ): Promise { await updateRows(await sharedTestOrm(testDb), Users, { id: userId }, data); } -import { SEARCH_TEXT_FIELD_MASK } from '../../../src/nest/maps/maps.helpers'; +import { SEARCH_TEXT_FIELD_MASK } from '../../../src/nest/maps/providers/google-places.constants'; const avatarsFx = makeStorageFixture('avatars/'); let profile: UserProfileService;