Possiblity to reconnect on Failed unkown (#11576)
Possiblity to reconnect you account on Failed Unkown errors. This PR triggers a similar flow than the Failed errors for unsufficient permission already existing in twenty. Allows our users to force the synchro again even though they have a strange error. It's been asked by some customers since we have had a couple of issues in messaging lately Fixes https://github.com/twentyhq/twenty/issues/11411
This commit is contained in:
@ -174,9 +174,12 @@ export class MessageChannelSyncStatusService {
|
||||
});
|
||||
}
|
||||
|
||||
public async markAsFailedUnknownAndFlushMessagesToImport(
|
||||
public async markAsFailedAndFlushMessagesToImport(
|
||||
messageChannelIds: string[],
|
||||
workspaceId: string,
|
||||
syncStatus:
|
||||
| MessageChannelSyncStatus.FAILED_INSUFFICIENT_PERMISSIONS
|
||||
| MessageChannelSyncStatus.FAILED_UNKNOWN,
|
||||
) {
|
||||
if (!messageChannelIds.length) {
|
||||
return;
|
||||
@ -195,41 +198,16 @@ export class MessageChannelSyncStatusService {
|
||||
|
||||
await messageChannelRepository.update(messageChannelIds, {
|
||||
syncStage: MessageChannelSyncStage.FAILED,
|
||||
syncStatus: MessageChannelSyncStatus.FAILED_UNKNOWN,
|
||||
syncStatus: syncStatus,
|
||||
});
|
||||
|
||||
const metricsKey =
|
||||
syncStatus === MessageChannelSyncStatus.FAILED_INSUFFICIENT_PERMISSIONS
|
||||
? MetricsKeys.MessageChannelSyncJobFailedInsufficientPermissions
|
||||
: MetricsKeys.MessageChannelSyncJobFailedUnknown;
|
||||
|
||||
await this.metricsService.batchIncrementCounter({
|
||||
key: MetricsKeys.MessageChannelSyncJobFailedUnknown,
|
||||
eventIds: messageChannelIds,
|
||||
});
|
||||
}
|
||||
|
||||
public async markAsFailedInsufficientPermissionsAndFlushMessagesToImport(
|
||||
messageChannelIds: string[],
|
||||
workspaceId: string,
|
||||
) {
|
||||
if (!messageChannelIds.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const messageChannelId of messageChannelIds) {
|
||||
await this.cacheStorage.del(
|
||||
`messages-to-import:${workspaceId}:${messageChannelId}`,
|
||||
);
|
||||
}
|
||||
|
||||
const messageChannelRepository =
|
||||
await this.twentyORMManager.getRepository<MessageChannelWorkspaceEntity>(
|
||||
'messageChannel',
|
||||
);
|
||||
|
||||
await messageChannelRepository.update(messageChannelIds, {
|
||||
syncStage: MessageChannelSyncStage.FAILED,
|
||||
syncStatus: MessageChannelSyncStatus.FAILED_INSUFFICIENT_PERMISSIONS,
|
||||
});
|
||||
|
||||
await this.metricsService.batchIncrementCounter({
|
||||
key: MetricsKeys.MessageChannelSyncJobFailedInsufficientPermissions,
|
||||
key: metricsKey,
|
||||
eventIds: messageChannelIds,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user