diff --git a/pkg/config/enum.go b/pkg/config/enum.go index 5988a68..fc355c6 100644 --- a/pkg/config/enum.go +++ b/pkg/config/enum.go @@ -135,12 +135,12 @@ var ( }, { Value: "novideo", - Label: "No webcam privileges", + Label: "No webcam privileges ('Shy Accounts')", Help: "The user can not broadcast or watch any webcam. Note: this option supercedes all other video-related rules.", }, { Value: "noimage", - Label: "No image sharing privileges", + Label: "No image sharing privileges ('Shy Accounts')", Help: "The user can not share or see any image shared on chat.", }, } diff --git a/pkg/controller/admin/user_actions.go b/pkg/controller/admin/user_actions.go index 769553d..de32497 100644 --- a/pkg/controller/admin/user_actions.go +++ b/pkg/controller/admin/user_actions.go @@ -139,18 +139,19 @@ func UserActions() http.HandlerFunc { if r.Method == http.MethodPost { // Rules list for the change log. var newRules = "(none)" - if rule, ok := r.PostForm["rules"]; ok { + if rule, ok := r.PostForm["rules"]; ok && len(rule) > 0 { newRules = strings.Join(rule, ",") user.SetProfileField("chat_moderation_rules", newRules) + if err := user.Save(); err != nil { + session.FlashError(w, r, "Error saving the user's chat rules: %s", err) + } else { + session.Flash(w, r, "Chat moderation rules have been updated!") + } } else { user.DeleteProfileField("chat_moderation_rules") + session.Flash(w, r, "All chat moderation rules have been cleared for user: %s", user.Username) } - if err := user.Save(); err != nil { - session.FlashError(w, r, "Error saving the user's chat rules: %s", err) - } else { - session.Flash(w, r, "Chat moderation rules have been updated!") - } templates.Redirect(w, "/u/"+user.Username) // Log the new rules to the changelog. diff --git a/pkg/models/user.go b/pkg/models/user.go index 1e84f69..d1b75c5 100644 --- a/pkg/models/user.go +++ b/pkg/models/user.go @@ -809,7 +809,7 @@ func (u *User) SetProfileField(name, value string) { // DeleteProfileField removes a stored profile field. func (u *User) DeleteProfileField(name string) error { - res := DB.Raw( + res := DB.Exec( "DELETE FROM profile_fields WHERE user_id=? AND name=?", u.ID, name, )