Skip to content

Commit

Permalink
review from charles
Browse files Browse the repository at this point in the history
  • Loading branch information
guillim committed Jan 15, 2025
1 parent f711d99 commit d9c0f4f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const seedMessageChannel = async (
type: 'email',
connectedAccountId: DEV_SEED_CONNECTED_ACCOUNT_IDS.TIM,
handle: '[email protected]',
isSyncEnabled: false,
visibility: MessageChannelVisibility.SHARE_EVERYTHING,
syncSubStatus: MessageChannelSyncStage.FULL_MESSAGE_LIST_FETCH_PENDING,
},
Expand All @@ -56,6 +57,7 @@ export const seedMessageChannel = async (
type: 'email',
connectedAccountId: DEV_SEED_CONNECTED_ACCOUNT_IDS.JONY,
handle: '[email protected]',
isSyncEnabled: false,
visibility: MessageChannelVisibility.SHARE_EVERYTHING,
syncSubStatus: MessageChannelSyncStage.FULL_MESSAGE_LIST_FETCH_PENDING,
},
Expand All @@ -68,6 +70,7 @@ export const seedMessageChannel = async (
type: 'email',
connectedAccountId: DEV_SEED_CONNECTED_ACCOUNT_IDS.PHIL,
handle: '[email protected]',
isSyncEnabled: false,
visibility: MessageChannelVisibility.SHARE_EVERYTHING,
syncSubStatus: MessageChannelSyncStage.FULL_MESSAGE_LIST_FETCH_PENDING,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ export enum MessageImportDriverExceptionCode {
UNKNOWN_NETWORK_ERROR = 'UNKNOWN_NETWORK_ERROR',
NO_NEXT_SYNC_CURSOR = 'NO_NEXT_SYNC_CURSOR',
SYNC_CURSOR_ERROR = 'SYNC_CURSOR_ERROR',
EXAMPLE_ACCOUNT = 'EXAMPLE_ACCOUNT',
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,11 @@ export class GmailGetMessageListService {
})
.catch((error) => {
if (connectedAccount.refreshToken === 'exampleRefreshToken') {
throw new MessageImportDriverException(
console.log(
`Gmail ${connectedAccount.handle} for connected account ${connectedAccount.id} not found. You probably use an example account, remove it`,
MessageImportDriverExceptionCode.EXAMPLE_ACCOUNT,
);
} else {
this.gmailHandleErrorService.handleGmailMessageListFetchError(
error,
);
}
this.gmailHandleErrorService.handleGmailMessageListFetchError(error);

return {
data: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,7 @@ export class MessageImportExceptionHandlerService {
);
break;
case MessageImportDriverExceptionCode.SYNC_CURSOR_ERROR:
await this.handleSyncCursorException(
exception,
messageChannel,
workspaceId,
);
break;
case MessageImportDriverExceptionCode.EXAMPLE_ACCOUNT:
await this.handleExampleAccountException(
await this.handlePermanentException(
exception,
messageChannel,
workspaceId,
Expand Down Expand Up @@ -163,7 +156,7 @@ export class MessageImportExceptionHandlerService {
);
}

private async handleSyncCursorException(
private async handlePermanentException(
exception: MessageImportDriverException,
messageChannel: Pick<MessageChannelWorkspaceEntity, 'id'>,
workspaceId: string,
Expand All @@ -173,25 +166,9 @@ export class MessageImportExceptionHandlerService {
workspaceId,
);

throw new MessageImportDriverException(
`SyncCursor error occurred while importing messages for message channel ${messageChannel.id} in workspace ${workspaceId}: ${exception.message}`,
MessageImportDriverExceptionCode.SYNC_CURSOR_ERROR,
);
}

private async handleExampleAccountException(
exception: MessageImportDriverException,
messageChannel: Pick<MessageChannelWorkspaceEntity, 'id'>,
workspaceId: string,
): Promise<void> {
await this.messageChannelSyncStatusService.markAsFailedUnknownAndFlushMessagesToImport(
[messageChannel.id],
workspaceId,
);

throw new MessageImportDriverException(
`Unvalid Account error occurred while importing messages for message channel ${messageChannel.id} in workspace ${workspaceId}: ${exception.message}`,
MessageImportDriverExceptionCode.EXAMPLE_ACCOUNT,
throw new MessageImportException(
`Permanent error occurred while importing messages for message channel ${messageChannel.id} in workspace ${workspaceId}: ${exception.message}`,
MessageImportExceptionCode.UNKNOWN,
);
}

Expand Down

0 comments on commit d9c0f4f

Please sign in to comment.