From a08a687951d613e4551774ba94c4a316a46018da Mon Sep 17 00:00:00 2001
From: Wingy <git@wingysam.xyz>
Date: Thu, 26 Oct 2023 19:32:33 -0700
Subject: [PATCH] refactor(server, web): standardize theme api response (#4664)

* web: standardize theme api response

* revert makefile change that i didn't mean to commit
---
 cli/src/api/open-api/api.ts                   |   4 ++--
 mobile/openapi/doc/ServerThemeDto.md          | Bin 450 -> 413 bytes
 .../openapi/lib/model/server_theme_dto.dart   | Bin 2763 -> 2790 bytes
 .../openapi/test/server_theme_dto_test.dart   | Bin 574 -> 568 bytes
 server/immich-openapi-specs.json              |   6 +++---
 .../src/domain/server-info/server-info.dto.ts |   4 +---
 .../domain/server-info/server-info.service.ts |   2 +-
 server/test/e2e/server-info.e2e-spec.ts       |   4 +---
 web/src/api/open-api/api.ts                   |   4 ++--
 web/src/routes/custom.css/+server.ts          |   4 +---
 10 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/cli/src/api/open-api/api.ts b/cli/src/api/open-api/api.ts
index 688fc7a488..809f3f0079 100644
--- a/cli/src/api/open-api/api.ts
+++ b/cli/src/api/open-api/api.ts
@@ -2966,10 +2966,10 @@ export interface ServerStatsResponseDto {
 export interface ServerThemeDto {
     /**
      * 
-     * @type {SystemConfigThemeDto}
+     * @type {string}
      * @memberof ServerThemeDto
      */
-    'theme': SystemConfigThemeDto;
+    'customCss': string;
 }
 /**
  * 
diff --git a/mobile/openapi/doc/ServerThemeDto.md b/mobile/openapi/doc/ServerThemeDto.md
index d79f55cf3a5c96f3f450bcb2ae55062e2d1ca8b7..506f60b7932cbe1246107fd98436d6431815a014 100644
GIT binary patch
delta 35
qcmX@aJePUGO^M{v;*$Ja=i*{5Erl8dEv?{^qRhN>Ev?C7jB5buUkoq+

delta 71
zcmbQse296%P1}-;)ZA1pErl9|Xf3Va%HopLT<83}w9NDnkc3M~zLr+31~zfM+!W1;
HAJ+f?s?8er

diff --git a/mobile/openapi/lib/model/server_theme_dto.dart b/mobile/openapi/lib/model/server_theme_dto.dart
index e803c588093c1a2e6b5e5536a70489d90324e42f..f31596033e3e037716816f6164f0b41f1bd2b410 100644
GIT binary patch
delta 227
zcmX>t`b=~~52H$QX>mz@u5)p*4wr&Lt)?{>kP0p-%FIhwfJ;r@##k%{=PB6QB1xGu
z1#-frCigNqh`@Qa2*W4eWQvl3OQ^>x*eaA{WESheg*Ll0XEK_=xmF6fi3MSaIi;!o
pX(5#bsWuQN*=b}I=jZ7t6sf~is&9VGa)T9NsXEvn)?Bq*TmVlUP~`vs

delta 200
zcmaDRdRlZt52IE|Mrv-V4wr&Lt)?{>kP5CWE=kRG&d*EBOb-Fcxs>E9fE7*Nz*x)&
zW+~X(LWL}u0$CxFlbIZNz${x8h`@8EC=oDAJyrpvJhNC2%-tNzoXKbmW?EsjO)sq|
iKi8``KTjhINJJN@LrvNIi{%EZ0E7c}ur*gL7Z(6tNkx+Y

diff --git a/mobile/openapi/test/server_theme_dto_test.dart b/mobile/openapi/test/server_theme_dto_test.dart
index c1f63ea499e620003b967e6a32e6d54c44639361..d340b8f55d2c408aefa1c94b6a2357d191532f02 100644
GIT binary patch
delta 41
ocmdnTvV&#Ac}D({qRhN>h2+xWlKfof;^N6K7!^4YJU%7^08&g3Qvd(}

delta 47
wcmdnNvX5oMc}B^~;*!){=ls01%=D0q)ZA2;l6-{{5M%N^MnzT#i-XAk0J_u>WdHyG

diff --git a/server/immich-openapi-specs.json b/server/immich-openapi-specs.json
index 58e0e3055a..d934d50b3c 100644
--- a/server/immich-openapi-specs.json
+++ b/server/immich-openapi-specs.json
@@ -7836,12 +7836,12 @@
       },
       "ServerThemeDto": {
         "properties": {
-          "theme": {
-            "$ref": "#/components/schemas/SystemConfigThemeDto"
+          "customCss": {
+            "type": "string"
           }
         },
         "required": [
-          "theme"
+          "customCss"
         ],
         "type": "object"
       },
diff --git a/server/src/domain/server-info/server-info.dto.ts b/server/src/domain/server-info/server-info.dto.ts
index 40a5f3a474..846458223d 100644
--- a/server/src/domain/server-info/server-info.dto.ts
+++ b/server/src/domain/server-info/server-info.dto.ts
@@ -80,9 +80,7 @@ export class ServerMediaTypesResponseDto {
   sidecar!: string[];
 }
 
-export class ServerThemeDto {
-  theme!: SystemConfigThemeDto;
-}
+export class ServerThemeDto extends SystemConfigThemeDto {}
 
 export class ServerConfigDto {
   oauthButtonText!: string;
diff --git a/server/src/domain/server-info/server-info.service.ts b/server/src/domain/server-info/server-info.service.ts
index bb1b22729b..f2d3123432 100644
--- a/server/src/domain/server-info/server-info.service.ts
+++ b/server/src/domain/server-info/server-info.service.ts
@@ -72,7 +72,7 @@ export class ServerInfoService {
 
   async getTheme() {
     const { theme } = await this.configCore.getConfig();
-    return { theme };
+    return theme;
   }
 
   async getConfig(): Promise<ServerConfigDto> {
diff --git a/server/test/e2e/server-info.e2e-spec.ts b/server/test/e2e/server-info.e2e-spec.ts
index 8f776187f4..a19c6235ee 100644
--- a/server/test/e2e/server-info.e2e-spec.ts
+++ b/server/test/e2e/server-info.e2e-spec.ts
@@ -161,9 +161,7 @@ describe(`${ServerInfoController.name} (e2e)`, () => {
       const { status, body } = await request(server).get('/server-info/theme');
       expect(status).toBe(200);
       expect(body).toEqual({
-        theme: {
-          customCss: '',
-        },
+        customCss: '',
       });
     });
   });
diff --git a/web/src/api/open-api/api.ts b/web/src/api/open-api/api.ts
index 688fc7a488..809f3f0079 100644
--- a/web/src/api/open-api/api.ts
+++ b/web/src/api/open-api/api.ts
@@ -2966,10 +2966,10 @@ export interface ServerStatsResponseDto {
 export interface ServerThemeDto {
     /**
      * 
-     * @type {SystemConfigThemeDto}
+     * @type {string}
      * @memberof ServerThemeDto
      */
-    'theme': SystemConfigThemeDto;
+    'customCss': string;
 }
 /**
  * 
diff --git a/web/src/routes/custom.css/+server.ts b/web/src/routes/custom.css/+server.ts
index d5ea304cd5..e71728f2a6 100644
--- a/web/src/routes/custom.css/+server.ts
+++ b/web/src/routes/custom.css/+server.ts
@@ -1,9 +1,7 @@
 import { RequestHandler, text } from '@sveltejs/kit';
 export const GET = (async ({ locals: { api } }) => {
   const {
-    data: {
-      theme: { customCss },
-    },
+    data: { customCss },
   } = await api.serverInfoApi.getTheme();
   return text(customCss, {
     headers: {