Remove utils.ClientCfg and utils.ClientCfgHash (#8041)
* remove utils.ClientCfg and utils.ClientCfgHash * remove unused import
Этот коммит содержится в:
@@ -37,12 +37,9 @@ const (
|
||||
var cfgMutex = &sync.Mutex{}
|
||||
var watcher *fsnotify.Watcher
|
||||
var Cfg *model.Config = &model.Config{}
|
||||
var CfgDiagnosticId = ""
|
||||
var CfgHash = ""
|
||||
var ClientCfgHash = ""
|
||||
var CfgFileName string = ""
|
||||
var CfgDisableConfigWatch = false
|
||||
var ClientCfg map[string]string = map[string]string{}
|
||||
var originalDisableDebugLvl l4g.Level = l4g.DEBUG
|
||||
var siteURL = ""
|
||||
|
||||
@@ -416,9 +413,6 @@ func LoadGlobalConfig(fileName string) *model.Config {
|
||||
|
||||
Cfg = config
|
||||
CfgHash = fmt.Sprintf("%x", md5.Sum([]byte(Cfg.ToJson())))
|
||||
ClientCfg = getClientConfig(Cfg)
|
||||
clientCfgJson, _ := json.Marshal(ClientCfg)
|
||||
ClientCfgHash = fmt.Sprintf("%x", md5.Sum(clientCfgJson))
|
||||
|
||||
SetSiteURL(*Cfg.ServiceSettings.SiteURL)
|
||||
|
||||
@@ -433,11 +427,7 @@ func InvokeGlobalConfigListeners(old, current *model.Config) {
|
||||
}
|
||||
}
|
||||
|
||||
func RegenerateClientConfig() {
|
||||
ClientCfg = getClientConfig(Cfg)
|
||||
}
|
||||
|
||||
func getClientConfig(c *model.Config) map[string]string {
|
||||
func GenerateClientConfig(c *model.Config, diagnosticId string) map[string]string {
|
||||
props := make(map[string]string)
|
||||
|
||||
props["Version"] = model.CurrentVersion
|
||||
@@ -544,7 +534,7 @@ func getClientConfig(c *model.Config) map[string]string {
|
||||
props["EnableUserTypingMessages"] = strconv.FormatBool(*c.ServiceSettings.EnableUserTypingMessages)
|
||||
props["EnableChannelViewedMessages"] = strconv.FormatBool(*c.ServiceSettings.EnableChannelViewedMessages)
|
||||
|
||||
props["DiagnosticId"] = CfgDiagnosticId
|
||||
props["DiagnosticId"] = diagnosticId
|
||||
props["DiagnosticsEnabled"] = strconv.FormatBool(*c.LogSettings.EnableDiagnostics)
|
||||
|
||||
props["PluginsEnabled"] = strconv.FormatBool(*c.PluginSettings.Enable)
|
||||
|
||||
@@ -299,7 +299,7 @@ func TestGetClientConfig(t *testing.T) {
|
||||
TranslationsPreInit()
|
||||
LoadGlobalConfig("config.json")
|
||||
|
||||
configMap := getClientConfig(Cfg)
|
||||
configMap := GenerateClientConfig(Cfg, "")
|
||||
if configMap["EmailNotificationContentsType"] != *Cfg.EmailSettings.EmailNotificationContentsType {
|
||||
t.Fatal("EmailSettings.EmailNotificationContentsType not exposed to client config")
|
||||
}
|
||||
|
||||
@@ -75,7 +75,24 @@ func LoadLicense(licenseBytes []byte) {
|
||||
l4g.Warn(T("utils.license.load_license.invalid.warn"))
|
||||
}
|
||||
|
||||
var licenseListeners = map[string]func(){}
|
||||
|
||||
func AddLicenseListener(listener func()) string {
|
||||
id := model.NewId()
|
||||
licenseListeners[id] = listener
|
||||
return id
|
||||
}
|
||||
|
||||
func RemoveLicenseListener(id string) {
|
||||
delete(licenseListeners, id)
|
||||
}
|
||||
|
||||
func SetLicense(license *model.License) bool {
|
||||
defer func() {
|
||||
for _, listener := range licenseListeners {
|
||||
listener()
|
||||
}
|
||||
}()
|
||||
|
||||
if license == nil {
|
||||
SetIsLicensed(false)
|
||||
@@ -95,7 +112,6 @@ func SetLicense(license *model.License) bool {
|
||||
licenseValue.Store(license)
|
||||
SetIsLicensed(true)
|
||||
clientLicenseValue.Store(getClientLicense(license))
|
||||
ClientCfg = getClientConfig(Cfg)
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -105,7 +121,6 @@ func SetLicense(license *model.License) bool {
|
||||
|
||||
func RemoveLicense() {
|
||||
SetLicense(nil)
|
||||
ClientCfg = getClientConfig(Cfg)
|
||||
}
|
||||
|
||||
func ValidateLicense(signed []byte) (bool, string) {
|
||||
|
||||
Ссылка в новой задаче
Block a user