mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 06:51:12 -05:00
19 lines
796 B
PL/PgSQL
19 lines
796 B
PL/PgSQL
-- Phase 1: Fix Realtime Subscriptions - Add realtime access helper function
|
|
-- Note: Realtime schema permissions are managed by Supabase automatically
|
|
-- Tables are already in the supabase_realtime publication with REPLICA IDENTITY FULL
|
|
|
|
-- Create a function to verify realtime access for moderators
|
|
CREATE OR REPLACE FUNCTION public.check_realtime_access()
|
|
RETURNS boolean
|
|
LANGUAGE plpgsql
|
|
STABLE SECURITY DEFINER
|
|
SET search_path = public
|
|
AS $$
|
|
BEGIN
|
|
-- Check if user is a moderator (can access realtime moderation features)
|
|
RETURN is_moderator(auth.uid());
|
|
END;
|
|
$$;
|
|
|
|
-- Add comment to the function
|
|
COMMENT ON FUNCTION public.check_realtime_access() IS 'Checks if the current user has permission to access realtime moderation features. Returns true for moderators, admins, and superusers.'; |