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.
38 lines
1.5 KiB
JavaScript
38 lines
1.5 KiB
JavaScript
const express = require("express")
|
|
const router = express.Router()
|
|
const userService = require("../../../services/userService")
|
|
const adminService = require("../../../services/adminService")
|
|
|
|
router.get("/:uuid", adminService.hasPermission("PLAYER_BAN_STATUS"), async (req, res) => {
|
|
const { uuid } = req.params
|
|
const banStatus = await userService.getPlayerBanStatus(uuid)
|
|
return res.status(200).json(banStatus)
|
|
})
|
|
|
|
router.get("/:uuid/actions", adminService.hasPermission("PLAYER_ACTIONS_LIST"), async (req, res) => {
|
|
const { uuid } = req.params
|
|
const playerActions = await userService.getPlayerActions(uuid)
|
|
return res.status(200).json(playerActions)
|
|
})
|
|
|
|
router.get("/:uuid/history", adminService.hasPermission("PLAYER_BAN_HISTORY"), async (req, res) => {
|
|
const { uuid } = req.params
|
|
const banHistory = await userService.getPlayerBans(uuid)
|
|
return res.status(200).json(banHistory)
|
|
})
|
|
|
|
router.put("/:uuid", adminService.hasPermission("PLAYER_BAN"), async (req, res) => {
|
|
const { reasonKey, reasonMessage, expires } = req.body
|
|
const ban = await userService.banUser(uuid, { reasonKey, reasonMessage, expires })
|
|
await adminService.logPlayerAction("BAN")
|
|
return res.status(200).json(ban)
|
|
})
|
|
|
|
router.delete("/:uuid", adminService.hasPermission("PLAYER_UNBAN"), async (req, res) => {
|
|
const { uuid } = req.params
|
|
const ban = await userService.unbanUser(uuid)
|
|
await adminService.logPlayerAction("UNBAN")
|
|
return res.status(200).json(ban)
|
|
})
|
|
|
|
module.exports = router |