mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 04:31:13 -05:00
Improve error handling and display for searches and uploads
Enhance user feedback by displaying search errors, refine photo submission fetching, add rate limiting cleanup logic, improve image upload cleanup, and strengthen moderator permission checks. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 2741d09b-80fb-4f0a-bfd6-ababb2ac4bfc Replit-Commit-Checkpoint-Type: intermediate_checkpoint
This commit is contained in:
@@ -66,9 +66,17 @@ Deno.serve(async (req) => {
|
||||
});
|
||||
}
|
||||
|
||||
const { data: isMod } = await supabase.rpc('is_moderator', { _user_id: user.id });
|
||||
const { data: isMod, error: modError } = await supabase.rpc('is_moderator', { _user_id: user.id });
|
||||
if (modError) {
|
||||
console.error('Failed to check moderator status:', modError);
|
||||
return new Response(JSON.stringify({ error: 'Failed to verify permissions' }), {
|
||||
status: 500,
|
||||
headers: { ...corsHeaders, 'Content-Type': 'application/json' }
|
||||
});
|
||||
}
|
||||
|
||||
if (!isMod) {
|
||||
return new Response(JSON.stringify({ error: 'Must be moderator' }), {
|
||||
return new Response(JSON.stringify({ error: 'Insufficient permissions. Moderator role required.' }), {
|
||||
status: 403,
|
||||
headers: { ...corsHeaders, 'Content-Type': 'application/json' }
|
||||
});
|
||||
@@ -94,6 +102,11 @@ Deno.serve(async (req) => {
|
||||
|
||||
// Helper to create submission
|
||||
async function createSubmission(userId: string, type: string, itemData: any, options: { escalated?: boolean; expiredLock?: boolean } = {}) {
|
||||
// Ensure crypto.randomUUID is available
|
||||
if (typeof crypto === 'undefined' || typeof crypto.randomUUID !== 'function') {
|
||||
throw new Error('crypto.randomUUID is not available in this environment');
|
||||
}
|
||||
|
||||
const submissionId = crypto.randomUUID();
|
||||
const itemId = crypto.randomUUID();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user