mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 08:51:13 -05:00
Fix submission status notifications
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user