diff options
author | John Molakvoæ <skjnldsv@protonmail.com> | 2022-10-20 16:03:19 +0200 |
---|---|---|
committer | John Molakvoæ <skjnldsv@protonmail.com> | 2022-11-29 11:23:05 +0100 |
commit | 064fa10ecfe4725398895a21ab8bafd171e2eadd (patch) | |
tree | 5f2d8124eb131a65eac207edee560c49ea7835f3 /apps/theming/lib/Controller | |
parent | cedae7c6d74e11c8aaa59b09a38db04dbebc818d (diff) | |
download | nextcloud-server-064fa10ecfe4725398895a21ab8bafd171e2eadd.tar.gz nextcloud-server-064fa10ecfe4725398895a21ab8bafd171e2eadd.zip |
Extract colour from custom background
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/theming/lib/Controller')
-rw-r--r-- | apps/theming/lib/Controller/UserThemeController.php | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/apps/theming/lib/Controller/UserThemeController.php b/apps/theming/lib/Controller/UserThemeController.php index 888ab9a0ca8..112a8a23638 100644 --- a/apps/theming/lib/Controller/UserThemeController.php +++ b/apps/theming/lib/Controller/UserThemeController.php @@ -168,9 +168,15 @@ class UserThemeController extends OCSController { /** * @NoAdminRequired */ - public function setBackground(string $type = BackgroundService::BACKGROUND_DEFAULT, string $value = ''): JSONResponse { + public function setBackground(string $type = BackgroundService::BACKGROUND_DEFAULT, string $value = '', string $color = null): JSONResponse { $currentVersion = (int)$this->config->getUserValue($this->userId, Application::APP_ID, 'userCacheBuster', '0'); + // Set color if provided + if ($color) { + $this->backgroundService->setColorBackground($color); + } + + // Set background image if provided try { switch ($type) { case BackgroundService::BACKGROUND_SHIPPED: @@ -179,14 +185,13 @@ class UserThemeController extends OCSController { case BackgroundService::BACKGROUND_CUSTOM: $this->backgroundService->setFileBackground($value); break; - case 'color': - $this->backgroundService->setColorBackground($value); - break; case BackgroundService::BACKGROUND_DEFAULT: $this->backgroundService->setDefaultBackground(); break; default: - return new JSONResponse(['error' => 'Invalid type provided'], Http::STATUS_BAD_REQUEST); + if (!$color) { + return new JSONResponse(['error' => 'Invalid type provided'], Http::STATUS_BAD_REQUEST); + } } } catch (\InvalidArgumentException $e) { return new JSONResponse(['error' => $e->getMessage()], Http::STATUS_BAD_REQUEST); |