mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-24 07:28:11 +02:00
fix: reset token status on update and suppress metric errors
This commit is contained in:
1 parent
566782fa82
commit
c37a56b366
2 files changed
+14
-3
No files matched your search
+7
-1
@@ -1310,10 +1310,16 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
|||||||
let pageData = insertSocialPageSchema.partial().parse(req.body);
|
let pageData = insertSocialPageSchema.partial().parse(req.body);
|
||||||
|
|
||||||
// If accessToken is being updated, recalculate expiration date (60 days from now)
|
// If accessToken is being updated, recalculate expiration date (60 days from now)
|
||||||
|
// AND reset the status to valid so the UI updates immediately
|
||||||
if (pageData.accessToken) {
|
if (pageData.accessToken) {
|
||||||
const tokenExpiresAt = new Date();
|
const tokenExpiresAt = new Date();
|
||||||
tokenExpiresAt.setDate(tokenExpiresAt.getDate() + 60);
|
tokenExpiresAt.setDate(tokenExpiresAt.getDate() + 60);
|
||||||
pageData = { ...pageData, tokenExpiresAt };
|
pageData = {
|
||||||
|
...pageData,
|
||||||
|
tokenExpiresAt,
|
||||||
|
tokenStatus: 'valid',
|
||||||
|
lastTokenCheck: new Date()
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const updatedPage = await storage.updateSocialPage(pageId, pageData);
|
const updatedPage = await storage.updateSocialPage(pageId, pageData);
|
||||||
|
|||||||
@@ -211,8 +211,13 @@ export class AnalyticsService {
|
|||||||
};
|
};
|
||||||
|
|
||||||
pageReach = findMetric('page_impressions');
|
pageReach = findMetric('page_impressions');
|
||||||
} catch (error) {
|
} catch (error: any) {
|
||||||
console.warn(`[AnalyticsService] Failed to fetch insights for ${pageId} (Permissions?):`, error);
|
// Code 100: Invalid Parameter (often means metric not available for this page type)
|
||||||
|
if (error.code === 100) {
|
||||||
|
console.warn(`[AnalyticsService] Metrics unavailable for ${pageId} (Code 100). This is likely due to page type restrictions. Skipping insights.`);
|
||||||
|
} else {
|
||||||
|
console.warn(`[AnalyticsService] Failed to fetch insights for ${pageId}:`, error.message);
|
||||||
|
}
|
||||||
// Continue execution to save at least the follower count
|
// Continue execution to save at least the follower count
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user