diff --git a/changelog/unreleased/fix-updating-logo-new-theme-structure.md b/changelog/unreleased/fix-updating-logo-new-theme-structure.md new file mode 100644 index 0000000000..884d8918b1 --- /dev/null +++ b/changelog/unreleased/fix-updating-logo-new-theme-structure.md @@ -0,0 +1,5 @@ +Bugfix: Updating logo with new theme structure + +Updating and resetting the logo when using the new `theme.json` structure in Web has been fixed. + +https://github.com/owncloud/ocis/pull/7930 diff --git a/services/web/pkg/service/v0/branding.go b/services/web/pkg/service/v0/branding.go index 4eae627320..7afaf46e04 100644 --- a/services/web/pkg/service/v0/branding.go +++ b/services/web/pkg/service/v0/branding.go @@ -145,17 +145,12 @@ func (p Web) getLogoPath(r io.Reader) (string, error) { var m map[string]interface{} _ = json.NewDecoder(r).Decode(&m) - webCfg, ok := m["web"].(map[string]interface{}) + webCfg, ok := m["clients"].(map[string]interface{})["web"].(map[string]interface{}) if !ok { return "", errInvalidThemeConfig } - defaultCfg, ok := webCfg["default"].(map[string]interface{}) - if !ok { - return "", errInvalidThemeConfig - } - - logoCfg, ok := defaultCfg["logo"].(map[string]interface{}) + logoCfg, ok := webCfg["defaults"].(map[string]interface{})["logo"].(map[string]interface{}) if !ok { return "", errInvalidThemeConfig } @@ -186,27 +181,19 @@ func (p Web) updateLogoThemeConfig(logoPath string) error { } commonCfg["logo"] = logoPath - webCfg, ok := m["web"].(map[string]interface{}) + webCfg, ok := m["clients"].(map[string]interface{})["web"].(map[string]interface{}) if !ok { return errInvalidThemeConfig } - // iterate over all possible themes and replace logo - for theme := range webCfg { - themeCfg, ok := webCfg[theme].(map[string]interface{}) - if !ok { - return errInvalidThemeConfig - } - - logoCfg, ok := themeCfg["logo"].(map[string]interface{}) - if !ok { - return errInvalidThemeConfig - } - - logoCfg["login"] = logoPath - logoCfg["topbar"] = logoPath + logoCfg, ok := webCfg["defaults"].(map[string]interface{})["logo"].(map[string]interface{}) + if !ok { + return errInvalidThemeConfig } + logoCfg["login"] = logoPath + logoCfg["topbar"] = logoPath + dst, err := p.fs.Create(_themesConfigPath) if err != nil { return err