mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 06:11:11 -05:00
Fix RLS policy for deletion
This commit is contained in:
@@ -418,7 +418,12 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((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<ModerationQueueRef>((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;
|
||||
|
||||
@@ -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()));
|
||||
Reference in New Issue
Block a user