diff options
| author | mhsanaei <ho3ein.sanaei@gmail.com> | 2025-09-18 14:56:04 +0300 |
|---|---|---|
| committer | mhsanaei <ho3ein.sanaei@gmail.com> | 2025-09-18 14:56:04 +0300 |
| commit | 59ea2645db827335a0689d2fb7aeeef4e52af52b (patch) | |
| tree | a52caa80571fef4919c3df59a4bceacd60ba6aa6 /web/service/setting.go | |
| parent | 8c8d280f147ce4e8f604080d1dbf066332e55efc (diff) | |
new: subJsonEnable
after this subEnable by default is true
and subJsonEnable is false
Diffstat (limited to 'web/service/setting.go')
| -rw-r--r-- | web/service/setting.go | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/web/service/setting.go b/web/service/setting.go index a54eaea7..39961ad5 100644 --- a/web/service/setting.go +++ b/web/service/setting.go @@ -50,7 +50,8 @@ var defaultValueMap = map[string]string{ "tgLang": "en-US", "twoFactorEnable": "false", "twoFactorToken": "", - "subEnable": "false", + "subEnable": "true", + "subJsonEnable": "false", "subTitle": "", "subListen": "", "subPort": "2096", @@ -427,6 +428,10 @@ func (s *SettingService) GetSubEnable() (bool, error) { return s.getBool("subEnable") } +func (s *SettingService) GetSubJsonEnable() (bool, error) { + return s.getBool("subJsonEnable") +} + func (s *SettingService) GetSubTitle() (string, error) { return s.getString("subTitle") } @@ -575,6 +580,7 @@ func (s *SettingService) GetDefaultSettings(host string) (any, error) { "defaultKey": func() (any, error) { return s.GetKeyFile() }, "tgBotEnable": func() (any, error) { return s.GetTgbotEnabled() }, "subEnable": func() (any, error) { return s.GetSubEnable() }, + "subJsonEnable": func() (any, error) { return s.GetSubJsonEnable() }, "subTitle": func() (any, error) { return s.GetSubTitle() }, "subURI": func() (any, error) { return s.GetSubURI() }, "subJsonURI": func() (any, error) { return s.GetSubJsonURI() }, @@ -593,7 +599,14 @@ func (s *SettingService) GetDefaultSettings(host string) (any, error) { result[key] = value } - if result["subEnable"].(bool) && (result["subURI"].(string) == "" || result["subJsonURI"].(string) == "") { + subEnable := result["subEnable"].(bool) + subJsonEnable := false + if v, ok := result["subJsonEnable"]; ok { + if b, ok2 := v.(bool); ok2 { + subJsonEnable = b + } + } + if (subEnable && result["subURI"].(string) == "") || (subJsonEnable && result["subJsonURI"].(string) == "") { subURI := "" subTitle, _ := s.GetSubTitle() subPort, _ := s.GetSubPort() @@ -619,13 +632,13 @@ func (s *SettingService) GetDefaultSettings(host string) (any, error) { } else { subURI += fmt.Sprintf("%s:%d", subDomain, subPort) } - if result["subURI"].(string) == "" { + if subEnable && result["subURI"].(string) == "" { result["subURI"] = subURI + subPath } if result["subTitle"].(string) == "" { result["subTitle"] = subTitle } - if result["subJsonURI"].(string) == "" { + if subJsonEnable && result["subJsonURI"].(string) == "" { result["subJsonURI"] = subURI + subJsonPath } } |
