mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 11:51:14 -05:00
Refactor realtime hooks
This commit is contained in:
@@ -2182,6 +2182,10 @@ export type Database = {
|
|||||||
Args: { _user_id: string }
|
Args: { _user_id: string }
|
||||||
Returns: boolean
|
Returns: boolean
|
||||||
}
|
}
|
||||||
|
check_realtime_access: {
|
||||||
|
Args: Record<PropertyKey, never>
|
||||||
|
Returns: boolean
|
||||||
|
}
|
||||||
extract_cf_image_id: {
|
extract_cf_image_id: {
|
||||||
Args: { url: string }
|
Args: { url: string }
|
||||||
Returns: string
|
Returns: string
|
||||||
|
|||||||
@@ -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.';
|
||||||
Reference in New Issue
Block a user