Add n8n test mode toggle and edge function improvements
- Add test/production toggle for n8n webhook URLs in IntegrasiTab - Update create-meet-link function to use database test_mode setting - Add send-email-v2 edge function for Mailketing API integration - Update daily-reminders and send-consultation-reminder to use send-email-v2 - Remove deprecated branding field from BrandingTab - Update domain references from hub.dwindi.com to with.dwindi.com - Add environment variables for Coolify deployment - Add comprehensive edge function test script - Update payment flow redirect to order detail page 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -127,22 +127,39 @@ serve(async (req: Request): Promise<Response> => {
|
||||
}
|
||||
}
|
||||
|
||||
// Send email if template is active and SMTP is configured
|
||||
if (template?.is_active && smtpSettings?.smtp_host && profile?.email) {
|
||||
// Replace shortcodes in email body
|
||||
let emailBody = template.email_body_html || "";
|
||||
let emailSubject = template.email_subject || "Reminder Konsultasi";
|
||||
// Send email if template is active and Mailketing is configured
|
||||
if (template?.is_active && smtpSettings?.api_token && profile?.email) {
|
||||
try {
|
||||
// Replace shortcodes in email body using master template system
|
||||
let emailBody = template.email_body_html || "";
|
||||
let emailSubject = template.email_subject || "Reminder Konsultasi";
|
||||
|
||||
Object.entries(payload).forEach(([key, value]) => {
|
||||
const regex = new RegExp(`\\{${key}\\}`, "g");
|
||||
emailBody = emailBody.replace(regex, String(value));
|
||||
emailSubject = emailSubject.replace(regex, String(value));
|
||||
});
|
||||
Object.entries(payload).forEach(([key, value]) => {
|
||||
const regex = new RegExp(`\\{${key}\\}`, "g");
|
||||
emailBody = emailBody.replace(regex, String(value));
|
||||
emailSubject = emailSubject.replace(regex, String(value));
|
||||
});
|
||||
|
||||
// Here you would send the actual email
|
||||
// For now, log that we would send it
|
||||
console.log("Would send reminder email to:", profile.email);
|
||||
console.log("Subject:", emailSubject);
|
||||
// Send via send-email-v2 (Mailketing API)
|
||||
const { error: emailError } = await supabase.functions.invoke("send-email-v2", {
|
||||
body: {
|
||||
to: profile.email,
|
||||
api_token: smtpSettings.api_token,
|
||||
from_name: smtpSettings.from_name || platformSettings?.brand_name || "Access Hub",
|
||||
from_email: smtpSettings.from_email || "noreply@with.dwindi.com",
|
||||
subject: emailSubject,
|
||||
html_body: emailBody,
|
||||
},
|
||||
});
|
||||
|
||||
if (emailError) {
|
||||
console.error("Failed to send reminder email:", emailError);
|
||||
} else {
|
||||
console.log("Reminder email sent to:", profile.email);
|
||||
}
|
||||
} catch (emailError) {
|
||||
console.error("Error sending reminder email:", emailError);
|
||||
}
|
||||
}
|
||||
|
||||
results.push({
|
||||
|
||||
Reference in New Issue
Block a user