diff --git a/api/ban.go b/api/ban.go index ca0ae3d..fd4cc3e 100644 --- a/api/ban.go +++ b/api/ban.go @@ -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 } diff --git a/api/kick.go b/api/kick.go index 6e43be6..4818a92 100644 --- a/api/kick.go +++ b/api/kick.go @@ -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 } diff --git a/api/main.go b/api/main.go index 1b0dca6..a53d457 100644 --- a/api/main.go +++ b/api/main.go @@ -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() } diff --git a/api/unban.go b/api/unban.go index 1775740..e21be31 100644 --- a/api/unban.go +++ b/api/unban.go @@ -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 }