Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bc45b0e7e8 |
+74
-20
@@ -112,13 +112,32 @@ export class MessageChannelSyncStatusService {
|
||||
'messageFolder',
|
||||
);
|
||||
|
||||
await messageChannelRepository.update(messageChannelIds, {
|
||||
syncCursor: '',
|
||||
syncStageStartedAt: null,
|
||||
throttleFailureCount: 0,
|
||||
throttleRetryAfter: null,
|
||||
pendingGroupEmailsAction: MessageChannelPendingGroupEmailsAction.NONE,
|
||||
});
|
||||
try {
|
||||
await messageChannelRepository.update(messageChannelIds, {
|
||||
syncCursor: '',
|
||||
syncStageStartedAt: null,
|
||||
throttleFailureCount: 0,
|
||||
throttleRetryAfter: null,
|
||||
pendingGroupEmailsAction: MessageChannelPendingGroupEmailsAction.NONE,
|
||||
});
|
||||
} catch (updateError) {
|
||||
if (
|
||||
updateError instanceof Error &&
|
||||
updateError.message.includes(
|
||||
'Field metadata for field "throttleRetryAfter" is missing',
|
||||
)
|
||||
) {
|
||||
await messageChannelRepository.update(messageChannelIds, {
|
||||
syncCursor: '',
|
||||
syncStageStartedAt: null,
|
||||
throttleFailureCount: 0,
|
||||
pendingGroupEmailsAction:
|
||||
MessageChannelPendingGroupEmailsAction.NONE,
|
||||
});
|
||||
} else {
|
||||
throw updateError;
|
||||
}
|
||||
}
|
||||
|
||||
await messageFolderRepository.update(
|
||||
{ messageChannelId: In(messageChannelIds) },
|
||||
@@ -222,14 +241,33 @@ export class MessageChannelSyncStatusService {
|
||||
'messageChannel',
|
||||
);
|
||||
|
||||
await messageChannelRepository.update(messageChannelIds, {
|
||||
syncStatus: MessageChannelSyncStatus.ACTIVE,
|
||||
syncStage: MessageChannelSyncStage.MESSAGE_LIST_FETCH_PENDING,
|
||||
throttleFailureCount: 0,
|
||||
throttleRetryAfter: null,
|
||||
syncStageStartedAt: null,
|
||||
syncedAt: new Date().toISOString(),
|
||||
});
|
||||
try {
|
||||
await messageChannelRepository.update(messageChannelIds, {
|
||||
syncStatus: MessageChannelSyncStatus.ACTIVE,
|
||||
syncStage: MessageChannelSyncStage.MESSAGE_LIST_FETCH_PENDING,
|
||||
throttleFailureCount: 0,
|
||||
throttleRetryAfter: null,
|
||||
syncStageStartedAt: null,
|
||||
syncedAt: new Date().toISOString(),
|
||||
});
|
||||
} catch (updateError) {
|
||||
if (
|
||||
updateError instanceof Error &&
|
||||
updateError.message.includes(
|
||||
'Field metadata for field "throttleRetryAfter" is missing',
|
||||
)
|
||||
) {
|
||||
await messageChannelRepository.update(messageChannelIds, {
|
||||
syncStatus: MessageChannelSyncStatus.ACTIVE,
|
||||
syncStage: MessageChannelSyncStage.MESSAGE_LIST_FETCH_PENDING,
|
||||
throttleFailureCount: 0,
|
||||
syncStageStartedAt: null,
|
||||
syncedAt: new Date().toISOString(),
|
||||
});
|
||||
} else {
|
||||
throw updateError;
|
||||
}
|
||||
}
|
||||
}, authContext);
|
||||
|
||||
await this.metricsService.batchIncrementCounter({
|
||||
@@ -306,11 +344,27 @@ export class MessageChannelSyncStatusService {
|
||||
'messageChannel',
|
||||
);
|
||||
|
||||
await messageChannelRepository.update(messageChannelIds, {
|
||||
syncStage: MessageChannelSyncStage.FAILED,
|
||||
syncStatus: syncStatus,
|
||||
throttleRetryAfter: null,
|
||||
});
|
||||
try {
|
||||
await messageChannelRepository.update(messageChannelIds, {
|
||||
syncStage: MessageChannelSyncStage.FAILED,
|
||||
syncStatus: syncStatus,
|
||||
throttleRetryAfter: null,
|
||||
});
|
||||
} catch (updateError) {
|
||||
if (
|
||||
updateError instanceof Error &&
|
||||
updateError.message.includes(
|
||||
'Field metadata for field "throttleRetryAfter" is missing',
|
||||
)
|
||||
) {
|
||||
await messageChannelRepository.update(messageChannelIds, {
|
||||
syncStage: MessageChannelSyncStage.FAILED,
|
||||
syncStatus: syncStatus,
|
||||
});
|
||||
} else {
|
||||
throw updateError;
|
||||
}
|
||||
}
|
||||
|
||||
const metricsKey =
|
||||
syncStatus === MessageChannelSyncStatus.FAILED_INSUFFICIENT_PERMISSIONS
|
||||
|
||||
+72
-25
@@ -32,21 +32,47 @@ export class MessagingCursorService {
|
||||
);
|
||||
|
||||
if (!folderId) {
|
||||
await messageChannelRepository.update(
|
||||
{
|
||||
id: messageChannel.id,
|
||||
},
|
||||
{
|
||||
throttleFailureCount: 0,
|
||||
throttleRetryAfter: null,
|
||||
syncStageStartedAt: null,
|
||||
syncCursor:
|
||||
!messageChannel.syncCursor ||
|
||||
nextSyncCursor > messageChannel.syncCursor
|
||||
? nextSyncCursor
|
||||
: messageChannel.syncCursor,
|
||||
},
|
||||
);
|
||||
try {
|
||||
await messageChannelRepository.update(
|
||||
{
|
||||
id: messageChannel.id,
|
||||
},
|
||||
{
|
||||
throttleFailureCount: 0,
|
||||
throttleRetryAfter: null,
|
||||
syncStageStartedAt: null,
|
||||
syncCursor:
|
||||
!messageChannel.syncCursor ||
|
||||
nextSyncCursor > messageChannel.syncCursor
|
||||
? nextSyncCursor
|
||||
: messageChannel.syncCursor,
|
||||
},
|
||||
);
|
||||
} catch (updateError) {
|
||||
if (
|
||||
updateError instanceof Error &&
|
||||
updateError.message.includes(
|
||||
'Field metadata for field "throttleRetryAfter" is missing',
|
||||
)
|
||||
) {
|
||||
await messageChannelRepository.update(
|
||||
{
|
||||
id: messageChannel.id,
|
||||
},
|
||||
{
|
||||
throttleFailureCount: 0,
|
||||
syncStageStartedAt: null,
|
||||
syncCursor:
|
||||
!messageChannel.syncCursor ||
|
||||
nextSyncCursor > messageChannel.syncCursor
|
||||
? nextSyncCursor
|
||||
: messageChannel.syncCursor,
|
||||
},
|
||||
);
|
||||
} else {
|
||||
throw updateError;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
await folderRepository.update(
|
||||
{
|
||||
@@ -56,16 +82,37 @@ export class MessagingCursorService {
|
||||
syncCursor: nextSyncCursor,
|
||||
},
|
||||
);
|
||||
await messageChannelRepository.update(
|
||||
{
|
||||
id: messageChannel.id,
|
||||
},
|
||||
{
|
||||
throttleFailureCount: 0,
|
||||
throttleRetryAfter: null,
|
||||
syncStageStartedAt: null,
|
||||
},
|
||||
);
|
||||
try {
|
||||
await messageChannelRepository.update(
|
||||
{
|
||||
id: messageChannel.id,
|
||||
},
|
||||
{
|
||||
throttleFailureCount: 0,
|
||||
throttleRetryAfter: null,
|
||||
syncStageStartedAt: null,
|
||||
},
|
||||
);
|
||||
} catch (updateError) {
|
||||
if (
|
||||
updateError instanceof Error &&
|
||||
updateError.message.includes(
|
||||
'Field metadata for field "throttleRetryAfter" is missing',
|
||||
)
|
||||
) {
|
||||
await messageChannelRepository.update(
|
||||
{
|
||||
id: messageChannel.id,
|
||||
},
|
||||
{
|
||||
throttleFailureCount: 0,
|
||||
syncStageStartedAt: null,
|
||||
},
|
||||
);
|
||||
} else {
|
||||
throw updateError;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, authContext);
|
||||
}
|
||||
|
||||
+21
-8
@@ -174,14 +174,27 @@ export class MessageImportExceptionHandlerService {
|
||||
? exception.throttleRetryAfter
|
||||
: undefined;
|
||||
|
||||
await messageChannelRepository.update(
|
||||
{ id: messageChannel.id },
|
||||
{
|
||||
throttleRetryAfter: isDefined(throttleRetryAfter)
|
||||
? throttleRetryAfter.toISOString()
|
||||
: null,
|
||||
},
|
||||
);
|
||||
try {
|
||||
await messageChannelRepository.update(
|
||||
{ id: messageChannel.id },
|
||||
{
|
||||
throttleRetryAfter: isDefined(throttleRetryAfter)
|
||||
? throttleRetryAfter.toISOString()
|
||||
: null,
|
||||
},
|
||||
);
|
||||
} catch (updateError) {
|
||||
if (
|
||||
!(
|
||||
updateError instanceof Error &&
|
||||
updateError.message.includes(
|
||||
'Field metadata for field "throttleRetryAfter" is missing',
|
||||
)
|
||||
)
|
||||
) {
|
||||
throw updateError;
|
||||
}
|
||||
}
|
||||
}, authContext);
|
||||
|
||||
switch (syncStep) {
|
||||
|
||||
+31
-10
@@ -202,16 +202,37 @@ export class MessagingMessagesImportService {
|
||||
'messageChannel',
|
||||
);
|
||||
|
||||
await messageChannelRepository.update(
|
||||
{
|
||||
id: messageChannel.id,
|
||||
},
|
||||
{
|
||||
throttleFailureCount: 0,
|
||||
throttleRetryAfter: null,
|
||||
syncStageStartedAt: null,
|
||||
},
|
||||
);
|
||||
try {
|
||||
await messageChannelRepository.update(
|
||||
{
|
||||
id: messageChannel.id,
|
||||
},
|
||||
{
|
||||
throttleFailureCount: 0,
|
||||
throttleRetryAfter: null,
|
||||
syncStageStartedAt: null,
|
||||
},
|
||||
);
|
||||
} catch (updateError) {
|
||||
if (
|
||||
updateError instanceof Error &&
|
||||
updateError.message.includes(
|
||||
'Field metadata for field "throttleRetryAfter" is missing',
|
||||
)
|
||||
) {
|
||||
await messageChannelRepository.update(
|
||||
{
|
||||
id: messageChannel.id,
|
||||
},
|
||||
{
|
||||
throttleFailureCount: 0,
|
||||
syncStageStartedAt: null,
|
||||
},
|
||||
);
|
||||
} else {
|
||||
throw updateError;
|
||||
}
|
||||
}
|
||||
|
||||
return await this.trackMessageImportCompleted(
|
||||
messageChannel,
|
||||
|
||||
Reference in New Issue
Block a user