Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

Merge origin/main into fix/google-workspace-session-observability

Gilad Resisi0d486f75e892
diff --cc libraries/nestjs-libraries/src/integrations/refresh.integration.service.ts
index 8fabd0b5c,bf59c32bb..8bed7b8be
--- a/libraries/nestjs-libraries/src/integrations/refresh.integration.service.ts
+++ b/libraries/nestjs-libraries/src/integrations/refresh.integration.service.ts
@@@ -73,31 -73,24 +73,35 @@@ export class RefreshIntegrationService
socialProvider: SocialProvider,
cause = ''
): Promise<AuthTokenDetails | false> {
+ let refreshError: any = undefined;
const refresh: false | AuthTokenDetails = await socialProvider
.refreshToken(integration.refreshToken)
- .catch((err) => false);
+ .catch((err) => {
+ refreshError = err;
+ return false as const;
+ });
if (!refresh || !refresh.accessToken) {
+ if (refreshError) {
+ console.error(
+ `Could not refresh ${integration.providerIdentifier} integration ${integration.id}`,
+ refreshError?.response?.data || refreshError?.message || refreshError
+ );
+ }
+
+ // informAboutRefreshError (with the failure cause) already notifies
+ // the user, and refreshNeeded sets the same flag disconnectChannel
+ // would β€” calling disconnectChannel here sent a second, cause-less
+ // copy of the same email for every failed refresh.
await this._integrationService.refreshNeeded(
integration.organizationId,
integration.id
);
- await this._integrationService.disconnectChannel(
+ await this._integrationService.informAboutRefreshError(
integration.organizationId,
integration,
- cause
+ socialProvider.refreshErrorMessage?.(refreshError) || cause
);
return false;