mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-11 17:26:45 +02:00
fix(server): Auto-expire invalid Facebook tokens on sync failure
This commit is contained in:
1 parent
8c911f0fb1
commit
54033ed6ed
1 file changed
+13
@@ -167,6 +167,19 @@ export class AnalyticsService {
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error(`[AnalyticsService] Failed to fetch basic info for ${pageId}:`, error);
|
||||
|
||||
// Check if it's an Auth Error (Token invalid/expired)
|
||||
// Codes: 190 (Invalid OAuth), 102 (API Session), 10 (Permission), 463 (Expired), 467 (Invalid)
|
||||
if (error.code === 190 || error.code === 463 || error.code === 467) {
|
||||
console.log(`[AnalyticsService] Marking token as EXPIRED for page ${pageId}`);
|
||||
await db.update(socialPages)
|
||||
.set({
|
||||
tokenStatus: "expired",
|
||||
lastTokenCheck: new Date()
|
||||
})
|
||||
.where(eq(socialPages.id, pageId));
|
||||
}
|
||||
|
||||
throw new Error(`Failed to fetch Basic Info: ${error.message || error}`);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user