mirror of
https://github.com/WiiLink24/wfc-server.git
synced 2026-09-12 10:35:46 -05:00
API: Add event logging
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user