add notification when user registers

This commit is contained in:
MaysWind
2024-08-08 22:29:01 +08:00
parent 32155ca63d
commit a4849fa4f0
4 changed files with 32 additions and 5 deletions
+4 -2
View File
@@ -279,8 +279,9 @@ type Config struct {
EnableDataExport bool
// Notification
AfterLoginNotification NotificationConfig
AfterOpenNotification NotificationConfig
AfterRegisterNotification NotificationConfig
AfterLoginNotification NotificationConfig
AfterOpenNotification NotificationConfig
// Map
MapProvider string
@@ -748,6 +749,7 @@ func loadDataConfiguration(config *Config, configFile *ini.File, sectionName str
}
func loadNotificationConfiguration(config *Config, configFile *ini.File, sectionName string) error {
config.AfterRegisterNotification = getNotificationConfiguration(configFile, sectionName, "enable_notification_after_register", "after_register_notification_content")
config.AfterLoginNotification = getNotificationConfiguration(configFile, sectionName, "enable_notification_after_login", "after_login_notification_content")
config.AfterOpenNotification = getNotificationConfiguration(configFile, sectionName, "enable_notification_after_open", "after_open_notification_content")
+19
View File
@@ -17,6 +17,25 @@ func SetCurrentConfig(config *Config) {
Container.Current = config
}
// GetAfterRegisterNotificationContent returns the notification content displayed each time users register
func (c *ConfigContainer) GetAfterRegisterNotificationContent(userLanguage string, clientLanguage string) string {
language := userLanguage
if language == "" {
language = clientLanguage
}
if !c.Current.AfterRegisterNotification.Enabled {
return ""
}
if multiLanguageContent, exists := c.Current.AfterRegisterNotification.MultiLanguageContent[language]; exists {
return multiLanguageContent
}
return c.Current.AfterRegisterNotification.DefaultContent
}
// GetAfterLoginNotificationContent returns the notification content displayed each time users log in
func (c *ConfigContainer) GetAfterLoginNotificationContent(userLanguage string, clientLanguage string) string {
language := userLanguage