Fix submission status notifications

This commit is contained in:
gpt-engineer-app[bot]
2025-10-23 18:54:00 +00:00
parent fa43787360
commit 79277c744a
2 changed files with 35 additions and 5 deletions

View File

@@ -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,

View File

@@ -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