Outlook integration (#9631)

Get Partial messages
This commit is contained in:
Guillim
2025-01-16 09:50:01 +01:00
committed by GitHub
parent 789ff30dc7
commit f077efd171
13 changed files with 165 additions and 32 deletions

View File

@ -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'>,

View File

@ -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`,

View File

@ -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,
);