diff --git a/supabase/functions/process-expired-bans/index.ts b/supabase/functions/process-expired-bans/index.ts index 79119505..3ab8f9ea 100644 --- a/supabase/functions/process-expired-bans/index.ts +++ b/supabase/functions/process-expired-bans/index.ts @@ -1,5 +1,9 @@ import { createClient } from 'https://esm.sh/@supabase/supabase-js@2.57.4'; -import { corsHeaders } from '../_shared/cors.ts'; + +const corsHeaders = { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type', +}; Deno.serve(async (req) => { // Handle CORS preflight diff --git a/supabase/migrations/20251030120421_35b04a1c-9d3b-490e-bbe4-14b80460a96c.sql b/supabase/migrations/20251030120421_35b04a1c-9d3b-490e-bbe4-14b80460a96c.sql new file mode 100644 index 00000000..ea19f119 --- /dev/null +++ b/supabase/migrations/20251030120421_35b04a1c-9d3b-490e-bbe4-14b80460a96c.sql @@ -0,0 +1,15 @@ +-- Enable pg_cron extension if not already enabled +CREATE EXTENSION IF NOT EXISTS pg_cron; + +-- Schedule the process-expired-bans function to run every hour +SELECT cron.schedule( + 'process-expired-bans', + '0 * * * *', -- Every hour at minute 0 + $$ + SELECT net.http_post( + url := 'https://ydvtmnrszybqnbcqbdcy.supabase.co/functions/v1/process-expired-bans', + headers := '{"Content-Type": "application/json", "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InlkdnRtbnJzenlicW5iY3FiZGN5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTgzMjYzNTYsImV4cCI6MjA3MzkwMjM1Nn0.DM3oyapd_omP5ZzIlrT0H9qBsiQBxBRgw2tYuqgXKX4"}'::jsonb, + body := '{}'::jsonb + ) as request_id; + $$ +); \ No newline at end of file