Optionally disable chat rate limiter and add optional chat slur/language filter (#3681)

* feat(chat): basic profanity filter. For #3139

* feat(chat): add setting for disabling chat spam protection. Closes #3523

* feat(chat): wire up the new chat slur filter to admin and chat. Closes #3139
This commit is contained in:
Gabe Kangas
2024-04-09 22:25:41 -07:00
committed by GitHub
parent 04eaf8c20e
commit a450e62397
14 changed files with 352 additions and 142 deletions

View File

@@ -59,6 +59,8 @@ const (
suggestedUsernamesKey = "suggested_usernames"
chatJoinMessagesEnabledKey = "chat_join_messages_enabled"
chatEstablishedUsersOnlyModeKey = "chat_established_users_only_mode"
chatSpamProtectionEnabledKey = "chat_spam_protection_enabled"
chatSlurFilterEnabledKey = "chat_slur_filter_enabled"
notificationsEnabledKey = "notifications_enabled"
discordConfigurationKey = "discord_configuration"
browserPushConfigurationKey = "browser_push_configuration"
@@ -528,6 +530,36 @@ func GetChatEstbalishedUsersOnlyMode() bool {
return false
}
// SetChatSpamProtectionEnabled will enable chat spam protection if set to true.
func SetChatSpamProtectionEnabled(enabled bool) error {
return _datastore.SetBool(chatSpamProtectionEnabledKey, enabled)
}
// GetChatSpamProtectionEnabled will return if chat spam protection is enabled.
func GetChatSpamProtectionEnabled() bool {
enabled, err := _datastore.GetBool(chatSpamProtectionEnabledKey)
if err == nil {
return enabled
}
return true
}
// SetChatSlurFilterEnabled will enable the chat slur filter.
func SetChatSlurFilterEnabled(enabled bool) error {
return _datastore.SetBool(chatSlurFilterEnabledKey, enabled)
}
// GetChatSlurFilterEnabled will return if the chat slur filter is enabled.
func GetChatSlurFilterEnabled() bool {
enabled, err := _datastore.GetBool(chatSlurFilterEnabledKey)
if err == nil {
return enabled
}
return false
}
// GetExternalActions will return the registered external actions.
func GetExternalActions() []models.ExternalAction {
configEntry, err := _datastore.Get(externalActionsKey)