feat(moderation): appeals (6c) + Discord reversal on approve (6d)
Players whose linked Discord identity was banned or muted can now submit an appeal from the portal and track it; staff get a queue in the admin moderation section to claim and resolve (approve/deny) appeals. Approving a ban/mute appeal best-effort asks the Discord bot to reverse the action (unban / clear timeout) via the internal API and posts a mod-log embed; a down bot never fails the resolution (reversal_status is recorded). - Schema: new server-owned `appeals` table (no cross-owner FK to mod_actions; existence validated in app code). - Server: model/appeals/* + player appeals controller (submit/mine/ eligible/withdraw) and admin queue handlers (list/claim/resolve/ per-user) under the existing admin+moderator gate; one-active-appeal enforced app-side; eligibility keyed on the caller's linked Discord id. - 6d: bot POST /internal/mod-reverse (+ modLog.postReversal) and server botInternalClient.reverseModAction, wired into resolve(). - Client: admin Appeals queue + resolve modal, ModerationUser appeals tab, player Appeals page (submit/withdraw), nav + routes + api methods. - Docs: swagger annotations + component schemas, regenerated output. - Tests: appeals controller + pure suites (server npm test 224 green). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmHdsbnLzDMAVQkAoTQSBe
This commit is contained in:
@@ -61,4 +61,15 @@ function announce({ title, excerpt, url, imageUrl }) {
|
||||
return call('/internal/announce', { method: 'POST', body: { title, excerpt, url, imageUrl } })
|
||||
}
|
||||
|
||||
module.exports = { pushConfig, getStatus, announce }
|
||||
// Site -> bot: an approved appeal wants the underlying Discord action reversed
|
||||
// (unban for a 'ban', clear the timeout for a 'mute'). Best-effort like every
|
||||
// call here — never throws, so an approved appeal still resolves when the bot is
|
||||
// down (the caller records reversal_status='failed' from `ok:false`).
|
||||
function reverseModAction({ discordUserId, actionType, appealId }) {
|
||||
return call('/internal/mod-reverse', {
|
||||
method: 'POST',
|
||||
body: { discord_user_id: discordUserId, action_type: actionType, appeal_id: appealId },
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { pushConfig, getStatus, announce, reverseModAction }
|
||||
|
||||
Reference in New Issue
Block a user