[calendar/messaging] fix connected account auth failed should skip sync (#4920)
- AuthFailedAt is set when a refreshToken is not valid and an accessToken can't be generated, meaning it will need a manual action from the user to provide a new refresh token. - Calendar/messaging jobs should not be executed if authFailedAt is not null.
This commit is contained in:
@ -63,6 +63,14 @@ export class GmailFetchMessageContentFromCacheService {
|
||||
return;
|
||||
}
|
||||
|
||||
if (connectedAccount.authFailedAt) {
|
||||
this.logger.error(
|
||||
`Connected account ${connectedAccountId} in workspace ${workspaceId} is in a failed state. Skipping...`,
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const accessToken = connectedAccount.accessToken;
|
||||
const refreshToken = connectedAccount.refreshToken;
|
||||
|
||||
@ -233,6 +241,14 @@ export class GmailFetchMessageContentFromCacheService {
|
||||
messageIdsToFetch,
|
||||
);
|
||||
|
||||
if (error?.message?.code === 429) {
|
||||
this.logger.error(
|
||||
`Error fetching messages for ${connectedAccountId} in workspace ${workspaceId}: Resource has been exhausted, locking for ${GMAIL_ONGOING_SYNC_TIMEOUT}ms...`,
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
await this.messageChannelRepository.updateSyncStatus(
|
||||
gmailMessageChannelId,
|
||||
MessageChannelSyncStatus.FAILED,
|
||||
|
||||
Reference in New Issue
Block a user