Skip to main content
The moderation Edge Function is the enforcement layer for Orbit’s moderation system. It handles warnings, account bans, installation-hash bans, and product enforcement checks. All operations run through server-side validation and protected RPC fallbacks.

Authentication and role resolution

The Edge Function authenticates the incoming JWT and resolves the admin role server-side. It does not trust client-reported roles. Role resolution queries user_roles directly, so JWT metadata tampering has no effect.

Input validation

Every request is validated before any state change. Invalid input returns an error without touching the database.

Enforcement operations

The moderation function supports three primary enforcement actions:
  • Warnings — recorded against an account for policy violations.
  • Account bans — disable access for a specific user.
  • Installation-hash bans — block a known device or installation hash.

Product enforcement check

Product enforcement calls the same function’s check operation. This lets the product surface query whether an account or installation is currently restricted without duplicating the moderation logic.

Batch revocation

Revocation timestamps a whole moderation batch and preserves its history. The operation does not delete past records; it marks the batch as revoked so the audit trail remains complete.

Protected RPC fallbacks

If the Edge Function is unavailable, the system falls back to protected RPCs. These RPCs enforce the same role checks and validation rules, so the authorization boundary does not weaken during fallback.
Do not expose moderation RPCs to the Supabase Data API or browser roles. They must remain callable only from trusted server contexts or the authenticated Edge Function.