Add audit log for moderation and admin actions

New audit_log table records actor, action, target and a JSON snapshot
of the details, so entries stay readable after the target is deleted;
the actor is set to NULL when the user is removed. logAudit() is called
from upload delete (single and bulk), comment delete, tag removal, role
create/delete, role permission changes, role assign/revoke and MOTD
updates. Logging failures only warn and never fail the action itself.

The admin page gets an audit card behind the new audit.view permission
with action filter, click-to-filter by user, readable summaries per
action and server-side pagination. Action catalog lives in
shared/utils/audit.ts, labels under admin.auditActions (de/en).

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-07 19:27:28 +02:00
co-authored by Claude Opus 5.5
parent 983c37f1db
commit 06ac414457
22 changed files with 1939 additions and 19 deletions
+38 -1
View File
@@ -212,7 +212,44 @@
"site": { "manage": "Manage site settings" },
"comment": { "delete": "Delete comments" },
"upload": { "delete": "Delete uploads" },
"tag": { "delete": "Delete tags" }
"tag": { "delete": "Delete tags" },
"audit": { "view": "View audit log" }
},
"audit": {
"title": "Audit log",
"desc": "Record of all moderation and admin actions. Click a name to filter by that user.",
"filterAction": "Filter by action",
"allActions": "All actions",
"filterUser": "Only show actions by {name}",
"clearUser": "Clear user filter",
"count": "{n} entries",
"refresh": "Refresh",
"time": "Time",
"actor": "User",
"action": "Action",
"details": "Details",
"deletedUser": "deleted user",
"empty": "No entries."
},
"auditActions": {
"delete_upload": "Upload deleted",
"bulk_delete_uploads": "Uploads bulk-deleted",
"delete_comment": "Comment deleted",
"remove_tags": "Tags removed",
"create_role": "Role created",
"delete_role": "Role deleted",
"update_role_permissions": "Permissions changed",
"assign_role": "Role assigned",
"remove_role": "Role revoked",
"update_motd": "Announcement changed"
},
"auditDetails": {
"deleteUpload": "{name} by {user}",
"bulkDelete": "{n} uploads",
"deleteComment": "{user}: {content}",
"role": "{role} → {user}",
"noChanges": "no changes",
"motdCleared": "Announcement removed"
}
},
"palette": {