Add player action logging for admin operations

Introduces a new addPlayerAction method in adminRepository and logPlayerAction in adminService to record admin actions on player accounts. Updates relevant admin routes to log actions such as bans, unbans, forced name changes, and skin resets. Also improves error messages in adminService for consistency and clarity.
This commit is contained in:
2026-01-05 05:06:06 +01:00
parent 439094013d
commit bfad2a39c1
5 changed files with 43 additions and 11 deletions

View File

@@ -119,10 +119,28 @@ async function getAdminByUsername(username) {
}
}
async function addPlayerAction(playerUuid, actionCode) {
try {
const cleanUuid = playerUuid.replace(/-/g, "")
const sql = "INSERT IGNORE INTO playerProfileActions (uuid, action) VALUES (?, ?)"
const result = await database.query(sql, [cleanUuid, actionCode])
return {
code: 200,
success: result.affectedRows > 0,
message: result.affectedRows > 0 ? "Action taken." : "Action already taken."
}
} catch (error) {
logger.log("Internal Server Error".bold + " : " + error.toString(), ["MariaDB", "yellow"])
throw new DefaultError(500, "Internal Server Error", "Database Error")
}
}
module.exports = {
createAdmin,
getAdminById,
hasPermission,
addPlayerAction,
assignPermission,
revokePermission,
getAdminByUsername,