[messaging] Fix thread cleaner service subqueries (#4416)

* [messaging] Fix thread cleaner service subqueries

* add pagination

* various fixes

* Fix thread merging

* fix

* fix
This commit is contained in:
Weiko
2024-03-12 17:49:45 +01:00
committed by GitHub
parent 91f4e1a853
commit 4476f5215b
17 changed files with 311 additions and 115 deletions

View File

@ -48,11 +48,19 @@ export class GmailPartialSyncService {
connectedAccountId: string,
maxResults = 500,
): Promise<void> {
const connectedAccount = await this.connectedAccountService.getByIdOrFail(
const connectedAccount = await this.connectedAccountService.getById(
connectedAccountId,
workspaceId,
);
if (!connectedAccount) {
this.logger.error(
`Connected account ${connectedAccountId} not found in workspace ${workspaceId} during partial-sync`,
);
return;
}
const lastSyncHistoryId = connectedAccount.lastSyncHistoryId;
if (!lastSyncHistoryId) {
@ -135,11 +143,19 @@ export class GmailPartialSyncService {
}
const gmailMessageChannel =
await this.messageChannelService.getFirstByConnectedAccountIdOrFail(
await this.messageChannelService.getFirstByConnectedAccountId(
connectedAccountId,
workspaceId,
);
if (!gmailMessageChannel) {
this.logger.error(
`No message channel found for connected account ${connectedAccountId} in workspace ${workspaceId} during partial-sync`,
);
return;
}
const gmailMessageChannelId = gmailMessageChannel.id;
const { messagesAdded, messagesDeleted } =