mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 12:11:17 -05:00
feat: Add automatic email signature
This commit is contained in:
@@ -78,6 +78,20 @@ const handler = async (req: Request): Promise<Response> => {
|
||||
return createErrorResponse({ message: 'Submission not found' }, 404, corsHeaders);
|
||||
}
|
||||
|
||||
// Fetch email signature from admin settings
|
||||
const { data: signatureSetting } = await supabase
|
||||
.from('admin_settings')
|
||||
.select('setting_value')
|
||||
.eq('setting_key', 'email.signature')
|
||||
.single();
|
||||
|
||||
const emailSignature = signatureSetting?.setting_value?.signature || '';
|
||||
|
||||
// Append signature to reply body if it exists
|
||||
const finalReplyBody = emailSignature
|
||||
? `${replyBody}\n\n---\n${emailSignature}`
|
||||
: replyBody;
|
||||
|
||||
// Rate limiting: max 10 replies per hour
|
||||
const oneHourAgo = new Date(Date.now() - 60 * 60 * 1000).toISOString();
|
||||
const { count } = await supabase
|
||||
@@ -124,7 +138,7 @@ const handler = async (req: Request): Promise<Response> => {
|
||||
from: 'ThrillWiki Admin <admin@thrillwiki.com>',
|
||||
to: `${submission.name} <${submission.email}>`,
|
||||
subject: finalSubject,
|
||||
text: replyBody,
|
||||
text: finalReplyBody,
|
||||
headers: {
|
||||
'Message-ID': messageId,
|
||||
'In-Reply-To': inReplyTo,
|
||||
@@ -156,7 +170,7 @@ const handler = async (req: Request): Promise<Response> => {
|
||||
from_email: 'admin@thrillwiki.com',
|
||||
to_email: submission.email,
|
||||
subject: finalSubject,
|
||||
body_text: replyBody,
|
||||
body_text: finalReplyBody,
|
||||
direction: 'outbound',
|
||||
sent_by: user.id,
|
||||
metadata: {
|
||||
|
||||
Reference in New Issue
Block a user