-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: fetch and parse full gmail message #5160
Merged
+232
−257
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
dc83466
fetch and parse full gmail message
rostaklein c2ec260
revert launch json
rostaklein 77aec94
Merge branch 'main' into gmail-full-message
charlesBochet d4831b0
Authorize case mismatch in mail headers parsing
charlesBochet 7a4446d
Reduce batch size
charlesBochet bc30639
stop storing errors in an array
rostaklein 5632a66
cc and bcc back
rostaklein daa91ca
remove unnecessary promises, working with GmailMessageError
rostaklein fb34418
handling all errors as failed status
rostaklein 40d2a6b
Merge branch 'twentyhq:main' into gmail-full-message
rostaklein e492f7a
Fixes
charlesBochet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ty-server/src/modules/messaging/constants/gmail-users-messages-get-batch-size.constant.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const GMAIL_USERS_MESSAGES_GET_BATCH_SIZE = 10; | ||
export const GMAIL_USERS_MESSAGES_GET_BATCH_SIZE = 20; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,7 +174,7 @@ export class GmailFetchMessageContentFromCacheService { | |
const messageQueries = createQueriesFromMessageIds(messageIdsToFetch); | ||
|
||
try { | ||
const { messages: messagesToSave, errors } = | ||
const messagesToSave = | ||
await this.fetchMessagesByBatchesService.fetchAllMessages( | ||
messageQueries, | ||
accessToken, | ||
|
@@ -194,22 +194,6 @@ export class GmailFetchMessageContentFromCacheService { | |
return []; | ||
} | ||
|
||
if (errors.length) { | ||
const errorsCanBeIgnored = errors.every( | ||
(error) => error.code === 404, | ||
); | ||
|
||
if (!errorsCanBeIgnored) { | ||
throw new Error( | ||
`Error fetching messages for ${connectedAccountId} in workspace ${workspaceId}: ${JSON.stringify( | ||
errors, | ||
null, | ||
2, | ||
)}`, | ||
); | ||
} | ||
} | ||
|
||
const messageExternalIdsAndIdsMap = | ||
await this.messageService.saveMessagesWithinTransaction( | ||
messagesToSave, | ||
|
@@ -292,21 +276,19 @@ export class GmailFetchMessageContentFromCacheService { | |
messageIdsToFetch, | ||
); | ||
|
||
if (error?.message?.code === 429) { | ||
this.logger.error( | ||
`Error fetching messages for ${connectedAccountId} in workspace ${workspaceId}: Resource has been exhausted, locking for ${GMAIL_ONGOING_SYNC_TIMEOUT}ms...`, | ||
); | ||
await this.messageChannelRepository.updateSyncStatus( | ||
gmailMessageChannelId, | ||
MessageChannelSyncStatus.FAILED, | ||
workspaceId, | ||
); | ||
Comment on lines
+279
to
+283
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is now being called for every single caught error, not just 429. I think thats what we actually want, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes! |
||
|
||
await this.messageChannelRepository.updateSyncStatus( | ||
gmailMessageChannelId, | ||
MessageChannelSyncStatus.FAILED, | ||
workspaceId, | ||
); | ||
this.logger.error( | ||
`Error fetching messages for ${connectedAccountId} in workspace ${workspaceId}: locking for ${GMAIL_ONGOING_SYNC_TIMEOUT}ms...`, | ||
); | ||
|
||
throw new Error( | ||
`Error fetching messages for ${connectedAccountId} in workspace ${workspaceId}: ${error.message}`, | ||
); | ||
} | ||
throw new Error( | ||
`Error fetching messages for ${connectedAccountId} in workspace ${workspaceId}: ${error.message}`, | ||
); | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rostaklein why are we removing these participants?