Skip to content

Commit 521f10f

Browse files
Copilotdevakesu
andauthored
Fix provider identification when both email providers fail (#59)
* Initial plan * Fix dual-provider failure to return secondary provider name Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com> * Add non-null assertion for secondaryName Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>
1 parent 7379ce1 commit 521f10f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/lib/email.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,15 @@ export async function sendEmail(props: SendEmailProps) {
135135
let primary: typeof sendViaSendPulse | typeof sendViaBrevo;
136136
let secondary: typeof sendViaSendPulse | typeof sendViaBrevo | null = null;
137137
let primaryName: string;
138+
let secondaryName: string | null = null;
138139

139140
// If both available, randomize
140141
if (hasBrevo && hasSendPulse) {
141142
const startWithSendPulse = Math.random() < 0.5;
142143
primary = startWithSendPulse ? sendViaSendPulse : sendViaBrevo;
143144
secondary = startWithSendPulse ? sendViaBrevo : sendViaSendPulse;
144145
primaryName = startWithSendPulse ? "SendPulse" : "Brevo";
146+
secondaryName = startWithSendPulse ? "Brevo" : "SendPulse";
145147
}
146148
// If only one available, use it
147149
else if (hasSendPulse) {
@@ -170,7 +172,7 @@ export async function sendEmail(props: SendEmailProps) {
170172
console.error("All email providers failed.");
171173
return {
172174
success: false,
173-
provider: "Brevo" as const,
175+
provider: secondaryName! as "Brevo" | "SendPulse",
174176
error: `Primary: ${primaryError.message} | Secondary: ${secondaryError.message}`,
175177
};
176178
}

0 commit comments

Comments
 (0)