mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 10:11:13 -05:00
Fix edge function console statements
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { createClient } from 'https://esm.sh/@supabase/supabase-js@2.57.4';
|
||||
import { edgeLogger } from '../_shared/logger.ts';
|
||||
|
||||
const corsHeaders = {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
@@ -35,16 +36,16 @@ Deno.serve(async (req) => {
|
||||
.lte('ban_expires_at', now);
|
||||
|
||||
if (fetchError) {
|
||||
console.error('Error fetching expired bans:', fetchError);
|
||||
edgeLogger.error('Error fetching expired bans', { action: 'process_expired_bans', error: fetchError });
|
||||
throw fetchError;
|
||||
}
|
||||
|
||||
console.log(`Found ${expiredBans?.length || 0} expired bans to process`);
|
||||
edgeLogger.info(`Found ${expiredBans?.length || 0} expired bans to process`, { action: 'process_expired_bans', count: expiredBans?.length || 0 });
|
||||
|
||||
// Unban users with expired bans
|
||||
const unbannedUsers: string[] = [];
|
||||
for (const profile of expiredBans || []) {
|
||||
console.log(`Unbanning user: ${profile.username} (${profile.user_id})`);
|
||||
edgeLogger.info('Unbanning user', { action: 'process_expired_bans', username: profile.username, userId: profile.user_id });
|
||||
|
||||
const { error: unbanError } = await supabaseAdmin
|
||||
.from('profiles')
|
||||
@@ -56,7 +57,7 @@ Deno.serve(async (req) => {
|
||||
.eq('user_id', profile.user_id);
|
||||
|
||||
if (unbanError) {
|
||||
console.error(`Failed to unban ${profile.username}:`, unbanError);
|
||||
edgeLogger.error('Failed to unban user', { action: 'process_expired_bans', username: profile.username, error: unbanError });
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -74,13 +75,13 @@ Deno.serve(async (req) => {
|
||||
});
|
||||
|
||||
if (logError) {
|
||||
console.error(`Failed to log auto-unban for ${profile.username}:`, logError);
|
||||
edgeLogger.error('Failed to log auto-unban', { action: 'process_expired_bans', username: profile.username, error: logError });
|
||||
}
|
||||
|
||||
unbannedUsers.push(profile.username);
|
||||
}
|
||||
|
||||
console.log(`Successfully unbanned ${unbannedUsers.length} users`);
|
||||
edgeLogger.info('Successfully unbanned users', { action: 'process_expired_bans', count: unbannedUsers.length });
|
||||
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
@@ -96,7 +97,7 @@ Deno.serve(async (req) => {
|
||||
);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error in process-expired-bans:', error);
|
||||
edgeLogger.error('Error in process-expired-bans', { action: 'process_expired_bans', error });
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
error: error instanceof Error ? error.message : 'Unknown error',
|
||||
|
||||
Reference in New Issue
Block a user