Fix email unconfirmed login flow with OTP resend and update email API field names
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { serve } from "https://deno.land/std@0.190.0/http/server.ts";
|
||||
import { createClient } from "https://esm.sh/@supabase/supabase-js@2";
|
||||
import { EmailTemplateRenderer } from "../shared/email-template-renderer.ts";
|
||||
|
||||
const corsHeaders = {
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
@@ -82,6 +83,14 @@ serve(async (req: Request): Promise<Response> => {
|
||||
.select("*")
|
||||
.single();
|
||||
|
||||
// Get platform settings for brand_name
|
||||
const { data: platformSettings } = await supabase
|
||||
.from("platform_settings")
|
||||
.select("brand_name")
|
||||
.single();
|
||||
|
||||
const brandName = platformSettings?.brand_name || "ACCESS HUB";
|
||||
|
||||
let notifyError = null;
|
||||
|
||||
if (template && emailSettings?.api_token) {
|
||||
@@ -98,6 +107,7 @@ serve(async (req: Request): Promise<Response> => {
|
||||
jam_konsultasi: `${slot.start_time.substring(0, 5)} - ${slot.end_time.substring(0, 5)} WIB`,
|
||||
link_meet: slot.meet_link || "Akan diinformasikan",
|
||||
jenis_konsultasi: slot.topic_category,
|
||||
platform_name: brandName,
|
||||
};
|
||||
|
||||
// Process shortcodes in template
|
||||
@@ -110,15 +120,22 @@ serve(async (req: Request): Promise<Response> => {
|
||||
emailSubject = emailSubject.replace(regex, String(value));
|
||||
});
|
||||
|
||||
// Wrap with master template
|
||||
const fullHtml = EmailTemplateRenderer.render({
|
||||
subject: emailSubject,
|
||||
content: emailBody,
|
||||
brandName: brandName,
|
||||
});
|
||||
|
||||
// Send via send-email-v2 (Mailketing API)
|
||||
const { error: emailError } = await supabase.functions.invoke("send-email-v2", {
|
||||
body: {
|
||||
to: profile.email,
|
||||
recipient: profile.email,
|
||||
api_token: emailSettings.api_token,
|
||||
from_name: emailSettings.from_name || "Access Hub",
|
||||
from_name: emailSettings.from_name || brandName,
|
||||
from_email: emailSettings.from_email || "noreply@with.dwindi.com",
|
||||
subject: emailSubject,
|
||||
html_body: emailBody,
|
||||
content: fullHtml,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user