API: Add event logging

This commit is contained in:
Palapeli
2026-04-05 09:57:09 -04:00
parent 1c44f521f3
commit d3b8508e6a
4 changed files with 27 additions and 0 deletions

View File

@@ -107,5 +107,14 @@ func handleBanImpl(r *http.Request) (bool, string, int) {
gpcm.KickPlayerCustomMessage(req.ProfileID, req.Reason, gpcm.WWFCMsgProfileRestrictedCustom)
logging.Event("profile_banned", map[string]any{
"profile_id": req.ProfileID,
"tos_violation": req.Tos,
"length_minutes": minutes,
"reason": req.Reason,
"reason_hidden": req.ReasonHidden,
"moderator": moderator,
})
return true, "", http.StatusOK
}

View File

@@ -6,6 +6,7 @@ import (
"net/http"
"strconv"
"wwfc/gpcm"
"wwfc/logging"
)
func HandleKick(w http.ResponseWriter, r *http.Request) {
@@ -79,5 +80,10 @@ func handleKickImpl(r *http.Request) (bool, string, int) {
gpcm.KickPlayerCustomMessage(req.ProfileID, req.Reason, gpcm.WWFCMsgKickedCustom)
logging.Event("profile_kicked", map[string]any{
"profile_id": req.ProfileID,
"reason": req.Reason,
})
return true, "", http.StatusOK
}

View File

@@ -19,7 +19,14 @@ func StartServer(reload bool) {
// Start SQL
db = database.Start(config)
db.RegisterEvents(config, []string{
"profile_kicked",
"profile_banned",
"profile_unbanned",
})
}
func Shutdown() {
db.Close()
}

View File

@@ -5,6 +5,7 @@ import (
"io"
"net/http"
"strconv"
"wwfc/logging"
)
func HandleUnban(w http.ResponseWriter, r *http.Request) {
@@ -75,5 +76,9 @@ func handleUnbanImpl(r *http.Request) (bool, string, int) {
return false, "Failed to unban user", http.StatusInternalServerError
}
logging.Event("profile_unbanned", map[string]any{
"profile_id": req.ProfileID,
})
return true, "", http.StatusOK
}