Merge messages and threads #1 (#3583)

* Merge messages and threads

* rename messageChannelSync to messageChannelMessage

* add merge logic

* remove deprecated methods

* restore enqueue GmailFullSyncJob after connectedAccount creation
This commit is contained in:
Weiko
2024-01-23 17:28:14 +01:00
committed by GitHub
parent 23a3614b54
commit dc7fccb0a8
13 changed files with 298 additions and 344 deletions

View File

@ -21,13 +21,14 @@ export class GoogleGmailService {
private readonly messageQueueService: MessageQueueService,
) {}
providerName = 'google';
async saveConnectedAccount(
saveConnectedAccountInput: SaveConnectedAccountInput,
) {
const {
handle,
workspaceId,
provider,
accessToken,
refreshToken,
workspaceMemberId,
@ -43,7 +44,7 @@ export class GoogleGmailService {
const connectedAccount = await workspaceDataSource?.query(
`SELECT * FROM ${dataSourceMetadata.schema}."connectedAccount" WHERE "handle" = $1 AND "provider" = $2 AND "accountOwnerId" = $3`,
[handle, provider, workspaceMemberId],
[handle, this.providerName, workspaceMemberId],
);
if (connectedAccount.length > 0) {
@ -60,7 +61,7 @@ export class GoogleGmailService {
[
connectedAccountId,
handle,
provider,
this.providerName,
accessToken,
refreshToken,
workspaceMemberId,
@ -69,7 +70,7 @@ export class GoogleGmailService {
await manager.query(
`INSERT INTO ${dataSourceMetadata.schema}."messageChannel" ("visibility", "handle", "connectedAccountId", "type") VALUES ($1, $2, $3, $4)`,
['share_everything', handle, connectedAccountId, 'gmail'],
['share_everything', handle, connectedAccountId, 'email'],
);
});