Bugfix when removing all chat moderation rules
This commit is contained in:
parent
066765d2dc
commit
9575041d1e
|
@ -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.",
|
||||
},
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user