mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-05-03 01:09:54 -05:00
fix: updating logo with new theme structure
Fixes updating and resetting the logo when using the new `theme.json` structure in Web.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user