From 79277c744ada98482e533d7a6b0ec182e345b65d Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Thu, 23 Oct 2025 18:54:00 +0000 Subject: [PATCH] Fix submission status notifications --- .../notify-moderators-report/index.ts | 34 +++++++++++++++++++ .../notify-moderators-submission/index.ts | 6 +--- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/supabase/functions/notify-moderators-report/index.ts b/supabase/functions/notify-moderators-report/index.ts index 10812339..3926a65b 100644 --- a/supabase/functions/notify-moderators-report/index.ts +++ b/supabase/functions/notify-moderators-report/index.ts @@ -96,6 +96,39 @@ serve(async (req) => { ); } + // Fetch reported entity name + let reportedEntityName = 'Unknown'; + + try { + if (payload.reportedEntityType === 'review') { + const { data: review } = await supabase + .from('reviews') + .select('ride:rides(name), park:parks(name)') + .eq('id', payload.reportedEntityId) + .maybeSingle(); + + reportedEntityName = review?.ride?.name || review?.park?.name || 'Review'; + } else if (payload.reportedEntityType === 'profile') { + const { data: profile } = await supabase + .from('profiles') + .select('display_name, username') + .eq('user_id', payload.reportedEntityId) + .maybeSingle(); + + reportedEntityName = profile?.display_name || profile?.username || 'User Profile'; + } else if (payload.reportedEntityType === 'content_submission') { + const { data: submission } = await supabase + .from('content_submissions') + .select('content') + .eq('id', payload.reportedEntityId) + .maybeSingle(); + + reportedEntityName = submission?.content?.name || 'Submission'; + } + } catch (error) { + console.warn('Could not fetch entity name:', error); + } + // Build enhanced notification payload const notificationPayload = { baseUrl: 'https://www.thrillwiki.com', @@ -106,6 +139,7 @@ serve(async (req) => { reporterName: payload.reporterName, reason: payload.reason, entityPreview: payload.entityPreview, + reportedEntityName, reportedAt: payload.reportedAt, relativeTime, priority, diff --git a/supabase/functions/notify-moderators-submission/index.ts b/supabase/functions/notify-moderators-submission/index.ts index 0b525ae0..ac340f85 100644 --- a/supabase/functions/notify-moderators-submission/index.ts +++ b/supabase/functions/notify-moderators-submission/index.ts @@ -120,7 +120,7 @@ serve(async (req) => { submitterName: submitter_name, submissionId: submission_id, action: action || 'create', - moderationUrl: `https://ydvtmnrszybqnbcqbdcy.supabase.co/admin/moderation`, + moderationUrl: 'https://www.thrillwiki.com/admin/moderation', // Enhanced content contentPreview: content_preview, @@ -134,10 +134,6 @@ serve(async (req) => { hasPhotos: has_photos, itemCount: item_count, isEscalated: is_escalated, - - // Request tracking - requestId: tracking.requestId, - traceId: tracking.traceId, }; // Send ONE notification to the moderation-submissions topic