@ -64,6 +64,13 @@ export class MessageImportExceptionHandlerService {
|
||||
workspaceId,
|
||||
);
|
||||
break;
|
||||
case MessageImportDriverExceptionCode.SYNC_CURSOR_ERROR:
|
||||
await this.handlePermanentException(
|
||||
exception,
|
||||
messageChannel,
|
||||
workspaceId,
|
||||
);
|
||||
break;
|
||||
default:
|
||||
throw exception;
|
||||
}
|
||||
@ -149,6 +156,22 @@ export class MessageImportExceptionHandlerService {
|
||||
);
|
||||
}
|
||||
|
||||
private async handlePermanentException(
|
||||
exception: MessageImportDriverException,
|
||||
messageChannel: Pick<MessageChannelWorkspaceEntity, 'id'>,
|
||||
workspaceId: string,
|
||||
): Promise<void> {
|
||||
await this.messageChannelSyncStatusService.markAsFailedUnknownAndFlushMessagesToImport(
|
||||
[messageChannel.id],
|
||||
workspaceId,
|
||||
);
|
||||
|
||||
throw new MessageImportException(
|
||||
`Permanent error occurred while importing messages for message channel ${messageChannel.id} in workspace ${workspaceId}: ${exception.message}`,
|
||||
MessageImportExceptionCode.UNKNOWN,
|
||||
);
|
||||
}
|
||||
|
||||
private async handleNotFoundException(
|
||||
syncStep: MessageImportSyncStep,
|
||||
messageChannel: Pick<MessageChannelWorkspaceEntity, 'id'>,
|
||||
|
||||
@ -29,7 +29,7 @@ export class MessagingGetMessageListService {
|
||||
public async getFullMessageList(
|
||||
connectedAccount: Pick<
|
||||
ConnectedAccountWorkspaceEntity,
|
||||
'provider' | 'refreshToken' | 'id'
|
||||
'provider' | 'refreshToken' | 'id' | 'handle'
|
||||
>,
|
||||
): Promise<GetFullMessageListResponse> {
|
||||
switch (connectedAccount.provider) {
|
||||
@ -63,11 +63,10 @@ export class MessagingGetMessageListService {
|
||||
syncCursor,
|
||||
);
|
||||
case 'microsoft':
|
||||
return {
|
||||
messageExternalIds: [],
|
||||
messageExternalIdsToDelete: [],
|
||||
nextSyncCursor: '',
|
||||
};
|
||||
return this.microsoftGetMessageListService.getPartialMessageList(
|
||||
connectedAccount,
|
||||
syncCursor,
|
||||
);
|
||||
default:
|
||||
throw new MessageImportException(
|
||||
`Provider ${connectedAccount.provider} is not supported`,
|
||||
|
||||
@ -58,13 +58,14 @@ export class MessagingMessageService {
|
||||
});
|
||||
|
||||
if (existingMessage) {
|
||||
await messageChannelMessageAssociationRepository.insert(
|
||||
await messageChannelMessageAssociationRepository.upsert(
|
||||
{
|
||||
messageChannelId,
|
||||
messageId: existingMessage.id,
|
||||
messageExternalId: message.externalId,
|
||||
messageThreadExternalId: message.messageThreadExternalId,
|
||||
},
|
||||
['messageChannelId', 'messageExternalId'],
|
||||
transactionManager,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user