Skip to content

Moderation Role — permissions system for content moderation with audit log #22

@Tresillo2017

Description

@Tresillo2017

Moderation Role

A dedicated moderation role with scoped permissions, separate from the full admin role.

Role hierarchy

Role Capabilities
user Browse, listen, like, comment, request sets
moderator + Review comments, approve/reject set requests, edit set metadata, manage tracklists
admin + All above + user management, system settings, delete anything

Moderator permissions

  • Sets: Add new sets (import from YouTube), edit metadata (title, artist, genre, venue, event), trigger detection, import tracklists
  • Tracklist: Edit track names/artists, link songs, trigger re-detection
  • Comments: Delete comments, mute users (temporary), approve reported content
  • Set Requests: Review, approve/reject, convert to set
  • Cannot: Delete sets permanently, manage users, access system settings, change roles

Implementation

  • role field on the users table: 'user' | 'moderator' | 'admin'
  • withModerator middleware (similar to existing withAdmin)
  • Update Better Auth session to include role
  • New "Moderation" section in the app (separate from full Admin panel)

Audit log

CREATE TABLE audit_log (
  id TEXT PRIMARY KEY,
  user_id TEXT NOT NULL,
  action TEXT NOT NULL,       -- e.g. 'set.edit', 'comment.delete', 'request.approve'
  target_type TEXT NOT NULL,  -- 'set' | 'comment' | 'request' | 'user'
  target_id TEXT NOT NULL,
  details TEXT,               -- JSON
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);

Admin UI

  • Manage roles from the Users tab
  • Audit log viewer with filtering by action type, user, date

Depends on

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions