Fix thread ID matching for email replies

This commit is contained in:
gpt-engineer-app[bot]
2025-10-28 20:29:14 +00:00
parent f57323aed4
commit 375db2e7d8
2 changed files with 65 additions and 13 deletions

View File

@@ -232,6 +232,13 @@ const handler = async (req: Request): Promise<Response> => {
}
});
// Update thread_id with Message-ID format (always, not just when email is sent)
const threadId = `${ticketNumber}.${submission.id}`;
await supabase
.from('contact_submissions')
.update({ thread_id: threadId })
.eq('id', submission.id);
if (forwardEmailKey) {
// Send admin notification
fetch('https://api.forwardemail.net/v1/emails', {
@@ -302,12 +309,6 @@ The ThrillWiki Team`,
}).catch(err => {
edgeLogger.error('Failed to send confirmation email', { requestId, error: err.message });
});
// Update thread_id with ticket number
await supabase
.from('contact_submissions')
.update({ thread_id: `ticket-${ticketNumber}` })
.eq('id', submission.id);
}
const duration = Date.now() - startTime;