From 25c9b779e4d19bc34551f8b137266a459e0d70e1 Mon Sep 17 00:00:00 2001 From: Jason Rasmussen Date: Fri, 29 Mar 2024 10:43:30 -0400 Subject: [PATCH] fix: map theme auth in shared links (#8359) fix: map theme auth --- mobile/openapi/doc/SystemConfigApi.md | 6 ++++-- mobile/openapi/lib/api/system_config_api.dart | 13 ++++++++++--- mobile/openapi/test/system_config_api_test.dart | 2 +- open-api/immich-openapi-specs.json | 8 ++++++++ open-api/typescript-sdk/src/fetch-client.ts | 4 +++- .../lib/components/shared-components/map/map.svelte | 3 ++- 6 files changed, 28 insertions(+), 8 deletions(-) diff --git a/mobile/openapi/doc/SystemConfigApi.md b/mobile/openapi/doc/SystemConfigApi.md index e782265b42172..2d1ce0da60f52 100644 --- a/mobile/openapi/doc/SystemConfigApi.md +++ b/mobile/openapi/doc/SystemConfigApi.md @@ -119,7 +119,7 @@ This endpoint does not need any parameter. [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **getMapStyle** -> Object getMapStyle(theme) +> Object getMapStyle(theme, key) @@ -143,9 +143,10 @@ import 'package:openapi/api.dart'; final api_instance = SystemConfigApi(); final theme = ; // MapTheme | +final key = key_example; // String | try { - final result = api_instance.getMapStyle(theme); + final result = api_instance.getMapStyle(theme, key); print(result); } catch (e) { print('Exception when calling SystemConfigApi->getMapStyle: $e\n'); @@ -157,6 +158,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **theme** | [**MapTheme**](.md)| | + **key** | **String**| | [optional] ### Return type diff --git a/mobile/openapi/lib/api/system_config_api.dart b/mobile/openapi/lib/api/system_config_api.dart index f13f8d52d04d0..276f8c07df483 100644 --- a/mobile/openapi/lib/api/system_config_api.dart +++ b/mobile/openapi/lib/api/system_config_api.dart @@ -102,7 +102,9 @@ class SystemConfigApi { /// Parameters: /// /// * [MapTheme] theme (required): - Future getMapStyleWithHttpInfo(MapTheme theme,) async { + /// + /// * [String] key: + Future getMapStyleWithHttpInfo(MapTheme theme, { String? key, }) async { // ignore: prefer_const_declarations final path = r'/system-config/map/style.json'; @@ -113,6 +115,9 @@ class SystemConfigApi { final headerParams = {}; final formParams = {}; + if (key != null) { + queryParams.addAll(_queryParams('', 'key', key)); + } queryParams.addAll(_queryParams('', 'theme', theme)); const contentTypes = []; @@ -132,8 +137,10 @@ class SystemConfigApi { /// Parameters: /// /// * [MapTheme] theme (required): - Future getMapStyle(MapTheme theme,) async { - final response = await getMapStyleWithHttpInfo(theme,); + /// + /// * [String] key: + Future getMapStyle(MapTheme theme, { String? key, }) async { + final response = await getMapStyleWithHttpInfo(theme, key: key, ); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } diff --git a/mobile/openapi/test/system_config_api_test.dart b/mobile/openapi/test/system_config_api_test.dart index fcf1ecfc5e9d9..0330d6a3d0d82 100644 --- a/mobile/openapi/test/system_config_api_test.dart +++ b/mobile/openapi/test/system_config_api_test.dart @@ -27,7 +27,7 @@ void main() { // TODO }); - //Future getMapStyle(MapTheme theme) async + //Future getMapStyle(MapTheme theme, { String key }) async test('test getMapStyle', () async { // TODO }); diff --git a/open-api/immich-openapi-specs.json b/open-api/immich-openapi-specs.json index 0bd6524db401d..a2aae92c41bca 100644 --- a/open-api/immich-openapi-specs.json +++ b/open-api/immich-openapi-specs.json @@ -5348,6 +5348,14 @@ "get": { "operationId": "getMapStyle", "parameters": [ + { + "name": "key", + "required": false, + "in": "query", + "schema": { + "type": "string" + } + }, { "name": "theme", "required": true, diff --git a/open-api/typescript-sdk/src/fetch-client.ts b/open-api/typescript-sdk/src/fetch-client.ts index 00794f12080c3..b9b4978a9bf9a 100644 --- a/open-api/typescript-sdk/src/fetch-client.ts +++ b/open-api/typescript-sdk/src/fetch-client.ts @@ -2422,13 +2422,15 @@ export function getConfigDefaults(opts?: Oazapfts.RequestOpts) { ...opts })); } -export function getMapStyle({ theme }: { +export function getMapStyle({ key, theme }: { + key?: string; theme: MapTheme; }, opts?: Oazapfts.RequestOpts) { return oazapfts.ok(oazapfts.fetchJson<{ status: 200; data: object; }>(`/system-config/map/style.json${QS.query(QS.explode({ + key, theme }))}`, { ...opts diff --git a/web/src/lib/components/shared-components/map/map.svelte b/web/src/lib/components/shared-components/map/map.svelte index 74643e502fb88..b42cf66498be1 100644 --- a/web/src/lib/components/shared-components/map/map.svelte +++ b/web/src/lib/components/shared-components/map/map.svelte @@ -2,7 +2,7 @@ import Icon from '$lib/components/elements/icon.svelte'; import { Theme } from '$lib/constants'; import { colorTheme, mapSettings } from '$lib/stores/preferences.store'; - import { getAssetThumbnailUrl, handlePromiseError } from '$lib/utils'; + import { getAssetThumbnailUrl, getKey, handlePromiseError } from '$lib/utils'; import { getMapStyle, MapTheme, type MapMarkerResponseDto } from '@immich/sdk'; import { mdiCog, mdiMapMarker } from '@mdi/js'; import type { Feature, GeoJsonProperties, Geometry, Point } from 'geojson'; @@ -50,6 +50,7 @@ $: style = (() => getMapStyle({ theme: ($mapSettings.allowDarkMode ? $colorTheme.value : Theme.LIGHT) as unknown as MapTheme, + key: getKey(), }) as Promise)(); const dispatch = createEventDispatcher<{