API for setting a list of blocked usernames. For #782

This commit is contained in:
Gabe Kangas
2021-05-22 21:50:34 -07:00
parent 83ad6db394
commit 61e07bf945
3 changed files with 49 additions and 17 deletions

View File

@@ -539,7 +539,19 @@ func SetCustomStyles(w http.ResponseWriter, r *http.Request) {
data.SetCustomStyles(customStyles.Value.(string))
controllers.WriteSimpleResponse(w, true, "custom styles updated")
}
// SetUsernameBlocklist will set the list of usernames we do not allow to use.
func SetUsernameBlocklist(w http.ResponseWriter, r *http.Request) {
usernames, success := getValueFromRequest(w, r)
if !success {
controllers.WriteSimpleResponse(w, false, "unable to update custom styles")
return
}
data.SetUsernameBlocklist(usernames.Value.(string))
controllers.WriteSimpleResponse(w, true, "blocklist updated")
}
func requirePOST(w http.ResponseWriter, r *http.Request) bool {