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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user