diff options
Diffstat (limited to 'core/data/config.go')
-rw-r--r-- | core/data/config.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/core/data/config.go b/core/data/config.go index 5ba076c45..a18f39cd7 100644 --- a/core/data/config.go +++ b/core/data/config.go @@ -58,6 +58,7 @@ const ( browserPushPublicKeyKey = "browser_push_public_key" browserPushPrivateKeyKey = "browser_push_private_key" hasConfiguredInitialNotificationsKey = "has_configured_initial_notifications" + suggestedUsernamesKey = "suggested_usernames" ) // GetExtraPageBodyContent will return the user-supplied body content. @@ -602,6 +603,26 @@ func SetForbiddenUsernameList(usernames []string) error { return _datastore.SetString(blockedUsernamesKey, usernameListString) } +// GetSuggestedUsernamesList will return the suggested usernames as a comma separated string. +// If the number of suggested usernames is smaller than 10, the number pool is not used (see code in the CreateAnonymousUser function). +func GetSuggestedUsernamesList() []string { + usernameString, err := _datastore.GetString(suggestedUsernamesKey) + + if err != nil || usernameString == "" { + return []string{} + } + + suggestionList := strings.Split(usernameString, ",") + + return suggestionList +} + +// SetSuggestedUsernamesList sets the username suggestion list as a comma separated string. +func SetSuggestedUsernamesList(usernames []string) error { + usernameListString := strings.Join(usernames, ",") + return _datastore.SetString(suggestedUsernamesKey, usernameListString) +} + // GetServerInitTime will return when the server was first setup. func GetServerInitTime() (*utils.NullTime, error) { var t utils.NullTime |