diff --git a/src/components/moderation/ModerationQueue.tsx b/src/components/moderation/ModerationQueue.tsx index cb24f4be..31913e25 100644 --- a/src/components/moderation/ModerationQueue.tsx +++ b/src/components/moderation/ModerationQueue.tsx @@ -418,7 +418,12 @@ export const ModerationQueue = forwardRef((props, ref) => { const skippedPhotos: string[] = []; if (item.content?.photos && Array.isArray(item.content.photos)) { + console.log('Processing photos from content:', item.content.photos); for (const photo of item.content.photos) { + console.log('Processing photo object:', photo); + console.log('Photo keys:', Object.keys(photo)); + console.log('photo.imageId:', photo.imageId, 'type:', typeof photo.imageId); + let imageId = ''; // First try to use the stored imageId directly @@ -507,7 +512,19 @@ export const ModerationQueue = forwardRef((props, ref) => { throw error; } - console.log('Submission successfully deleted from database'); + // Verify the deletion actually worked + const { data: checkData, error: checkError } = await supabase + .from('content_submissions') + .select('id') + .eq('id', item.id) + .single(); + + if (checkData && !checkError) { + console.error('DELETION FAILED: Item still exists in database after delete operation'); + throw new Error('Deletion failed - item still exists in database'); + } else { + console.log('Verified: Submission successfully deleted from database'); + } const deletedCount = validImageIds.length; const orphanedCount = skippedPhotos.length; diff --git a/supabase/migrations/20250929022348_18fea241-7d6f-4945-9956-5f968e9d4cb0.sql b/supabase/migrations/20250929022348_18fea241-7d6f-4945-9956-5f968e9d4cb0.sql new file mode 100644 index 00000000..49637840 --- /dev/null +++ b/supabase/migrations/20250929022348_18fea241-7d6f-4945-9956-5f968e9d4cb0.sql @@ -0,0 +1,5 @@ +-- Add DELETE policy for moderators on content_submissions table +CREATE POLICY "Moderators can delete content submissions" +ON public.content_submissions +FOR DELETE +USING (is_moderator(auth.uid())); \ No newline at end of file