wfc-server/api/unban.go
Palapeli b70c693d26
Some checks failed
Build CI / build (push) Has been cancelled
golangci-lint / lint (push) Has been cancelled
API: Reformat API error responses
2026-04-24 12:15:57 -04:00

39 lines
719 B
Go

package api
import (
"net/http"
"wwfc/logging"
"github.com/logrusorgru/aurora/v3"
)
type UnbanRequestSpec struct {
AuthInfo
ProfileID uint32 `json:"pid"`
}
func HandleUnban(w http.ResponseWriter, r *http.Request) {
var req UnbanRequestSpec
if err := parsePost(r, w, &req, RoleModerator); err != nil {
return
}
if req.ProfileID == 0 {
replyError(w, http.StatusBadRequest, APIErrorInvalidProfileID)
return
}
if !db.UnbanUser(req.ProfileID) {
replyError(w, http.StatusInternalServerError, APIErrorUnbanFailed)
return
}
replyOK(w, nil)
logging.Event("profile_unbanned", map[string]any{
"profile_id": req.ProfileID,
})
logging.Notice("API:admin", "Unban:", aurora.Cyan(req.ProfileID))
}