Refactor realtime hooks

This commit is contained in:
gpt-engineer-app[bot]
2025-10-02 20:39:37 +00:00
parent 15caad0c8e
commit 63e8370991
2 changed files with 23 additions and 0 deletions

View File

@@ -2182,6 +2182,10 @@ export type Database = {
Args: { _user_id: string }
Returns: boolean
}
check_realtime_access: {
Args: Record<PropertyKey, never>
Returns: boolean
}
extract_cf_image_id: {
Args: { url: string }
Returns: string

View File

@@ -0,0 +1,19 @@
-- 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.';