57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
package settings
|
|
|
|
// ConfigContainer contains the current setting config
|
|
type ConfigContainer struct {
|
|
Current *Config
|
|
}
|
|
|
|
// Initialize a config container singleton instance
|
|
var (
|
|
Version string
|
|
CommitHash string
|
|
Container = &ConfigContainer{}
|
|
)
|
|
|
|
// SetCurrentConfig sets the current config by a given config
|
|
func SetCurrentConfig(config *Config) {
|
|
Container.Current = config
|
|
}
|
|
|
|
// GetAfterLoginNotificationContent returns the notification content displayed each time users log in
|
|
func (c *ConfigContainer) GetAfterLoginNotificationContent(userLanguage string, clientLanguage string) string {
|
|
language := userLanguage
|
|
|
|
if language == "" {
|
|
language = clientLanguage
|
|
}
|
|
|
|
if !c.Current.AfterLoginNotification.Enabled {
|
|
return ""
|
|
}
|
|
|
|
if multiLanguageContent, exists := c.Current.AfterLoginNotification.MultiLanguageContent[language]; exists {
|
|
return multiLanguageContent
|
|
}
|
|
|
|
return c.Current.AfterLoginNotification.DefaultContent
|
|
}
|
|
|
|
// GetAfterOpenNotificationContent returns the notification content displayed each time users open the app
|
|
func (c *ConfigContainer) GetAfterOpenNotificationContent(userLanguage string, clientLanguage string) string {
|
|
language := userLanguage
|
|
|
|
if language == "" {
|
|
language = clientLanguage
|
|
}
|
|
|
|
if !c.Current.AfterOpenNotification.Enabled {
|
|
return ""
|
|
}
|
|
|
|
if multiLanguageContent, exists := c.Current.AfterOpenNotification.MultiLanguageContent[language]; exists {
|
|
return multiLanguageContent
|
|
}
|
|
|
|
return c.Current.AfterOpenNotification.DefaultContent
|
|
}
|