Skip to content

Commit

Permalink
fix(theming): Stop leaking user theme into capabilities
Browse files Browse the repository at this point in the history
Signed-off-by: jld3103 <jld3103yt@gmail.com>
  • Loading branch information
provokateurin committed Oct 23, 2023
1 parent 73a6061 commit 837eb45
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
15 changes: 9 additions & 6 deletions apps/theming/lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,26 @@ public function __construct(ThemingDefaults $theming, Util $util, IURLGenerator
* }
*/
public function getCapabilities() {
$color = $this->theming->getDefaultColorPrimary();
$colorText = $this->theming->getDefaultTextColorPrimary();

$backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', '');
$color = $this->theming->getColorPrimary();
$backgroundPlain = $backgroundLogo === 'backgroundColor' || ($backgroundLogo === '' && $color !== '#0082c9');
$background = $backgroundPlain ? $color : $this->url->getAbsoluteURL($this->theming->getBackground());

return [
'theming' => [
'name' => $this->theming->getName(),
'url' => $this->theming->getBaseUrl(),
'slogan' => $this->theming->getSlogan(),
'color' => $color,
'color-text' => $this->theming->getTextColorPrimary(),
'color-text' => $colorText,
'color-element' => $this->util->elementColor($color),
'color-element-bright' => $this->util->elementColor($color),
'color-element-dark' => $this->util->elementColor($color, false),
'logo' => $this->url->getAbsoluteURL($this->theming->getLogo()),
'background' => $backgroundLogo === 'backgroundColor' || ($backgroundLogo === '' && $this->theming->getColorPrimary() !== '#0082c9') ?
$this->theming->getColorPrimary() :
$this->url->getAbsoluteURL($this->theming->getBackground()),
'background-plain' => $backgroundLogo === 'backgroundColor' || ($backgroundLogo === '' && $this->theming->getColorPrimary() !== '#0082c9'),
'background' => $background,
'background-plain' => $backgroundPlain,
'background-default' => !$this->util->isBackgroundThemed(),
'logoheader' => $this->url->getAbsoluteURL($this->theming->getLogo()),
'favicon' => $this->url->getAbsoluteURL($this->theming->getLogo()),
Expand Down
4 changes: 2 additions & 2 deletions apps/theming/tests/CapabilitiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ public function testGetCapabilities($name, $url, $slogan, $color, $textColor, $l
->method('getSlogan')
->willReturn($slogan);
$this->theming->expects($this->atLeast(1))
->method('getColorPrimary')
->method('getDefaultColorPrimary')
->willReturn($color);
$this->theming->expects($this->exactly(3))
->method('getLogo')
->willReturn($logo);
$this->theming->expects($this->once())
->method('getTextColorPrimary')
->method('getDefaultTextColorPrimary')
->willReturn($textColor);

$util = new Util($this->config, $this->createMock(IAppManager::class), $this->createMock(IAppData::class), $this->createMock(ImageManager::class));
Expand Down

0 comments on commit 837eb45

Please sign in to comment.