Skip to content

Commit 82662e7

Browse files
authored
Merge pull request #2648 from ankaboot-source/docs/update-readme-features
fix(campaigns): add early logging and English messages
2 parents c6ef8f3 + 6de41c8 commit 82662e7

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

supabase/functions/email-campaigns/index.ts

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ function getUserFriendlyError(error: unknown): string {
299299
message.includes("authentication") ||
300300
message.includes("Username and Password not accepted")
301301
) {
302-
return "Identifiants OAuth invalides ou token expiré. Veuillez reconnecter ce compte.";
302+
return "Invalid OAuth credentials or expired token. Please reconnect this account.";
303303
}
304304

305305
// Detect connection/timeout errors
@@ -309,7 +309,7 @@ function getUserFriendlyError(error: unknown): string {
309309
message.includes("ECONNREFUSED") ||
310310
message.includes("ENOTFOUND")
311311
) {
312-
return "Impossible de se connecter au serveur SMTP. Veuillez réessayer plus tard.";
312+
return "Cannot connect to SMTP server. Please try again later.";
313313
}
314314

315315
// Detect rate limiting
@@ -318,7 +318,7 @@ function getUserFriendlyError(error: unknown): string {
318318
message.includes("throttl") ||
319319
message.includes("429")
320320
) {
321-
return "Trop de requêtes. Veuillez réessayer plus tard.";
321+
return "Too many requests. Please try again later.";
322322
}
323323

324324
// Default: return the original message but truncated
@@ -662,8 +662,35 @@ async function resolveSenderOptions(authorization: string, userEmail: string) {
662662
}
663663

664664
for (const source of sources) {
665+
const expiresAt = source.credentials.expiresAt;
666+
const nowMs = Date.now();
667+
console.log(
668+
"[OAuth] Checking source:",
669+
source.email,
670+
"- type:",
671+
source.type,
672+
"- expiresAt:",
673+
expiresAt,
674+
"- now:",
675+
nowMs,
676+
"- isExpired:",
677+
expiresAt && expiresAt <= nowMs,
678+
);
679+
665680
const credentialIssue = getSenderCredentialIssue(source);
681+
console.log(
682+
"[OAuth] Credential issue for",
683+
source.email,
684+
":",
685+
credentialIssue,
686+
);
687+
666688
if (credentialIssue) {
689+
console.log(
690+
"[OAuth] Token EXPIRED for:",
691+
source.email,
692+
"- will attempt refresh",
693+
);
667694
options.push({
668695
email: source.email,
669696
available: false,

supabase/functions/email-campaigns/sender-options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export function getSenderCredentialIssue(
171171

172172
const expiresAt = Number(source.credentials.expiresAt);
173173
if (Number.isFinite(expiresAt) && expiresAt > 0 && expiresAt <= nowMs) {
174-
return "Token OAuth expiré. Veuillez reconnecter ce compte dans les sources.";
174+
return "OAuth token expired. Please reconnect this account in sources.";
175175
}
176176

177177
return null;

0 commit comments

Comments
 (0)