Skip to content

Commit 4953f2d

Browse files
authored
Merge pull request #2650 from ankaboot-source/docs/update-readme-features
fix(campaigns): handle both string and numeric expiresAt format
2 parents cd9197b + baf537e commit 4953f2d

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,27 @@ export function getSenderCredentialIssue(
169169
return null;
170170
}
171171

172-
const expiresAt = Number(source.credentials.expiresAt);
173-
if (Number.isFinite(expiresAt) && expiresAt > 0 && expiresAt <= nowMs) {
172+
let expiresAt = source.credentials.expiresAt;
173+
174+
// Handle both numeric timestamp and ISO date string
175+
if (typeof expiresAt === "string") {
176+
expiresAt = new Date(expiresAt).getTime();
177+
}
178+
179+
const numericExpiresAt = Number(expiresAt);
180+
if (
181+
Number.isFinite(numericExpiresAt) &&
182+
numericExpiresAt > 0 &&
183+
numericExpiresAt <= nowMs
184+
) {
185+
console.log(
186+
"[OAuth] Token IS EXPIRED for:",
187+
source.email,
188+
"- expiresAt:",
189+
numericExpiresAt,
190+
"- now:",
191+
nowMs,
192+
);
174193
return "OAuth token expired. Please reconnect this account in sources.";
175194
}
176195

0 commit comments

Comments
 (0)