4398 decouple contacts and companies creation from messages import (#4590)

* emit event

* create queue and listener

* filter participants with role 'from'

* create job

* Add job to job module

* Refactoring

* Refactor contact creation in CreateCompanyAndContactService

* update job

* wip

* add getByHandlesWithoutPersonIdAndWorkspaceMemberId to calendar event attendee repository

* refactoring

* refactoring

* Revert "refactoring"

This reverts commit e5434f0b871e45447227aa8d55ba5af381c3ff1c.

* fix nest imports

* add await

* fix contact creation condition

* emit contact creation event after calendar-full-sync

* add await

* add missing transactionManager

* calendar event attendees personId update is working

* messageParticipant and calendarEventAttendee update is working as intended

* rename module

* fix lodash import

* add test

* update package.json
This commit is contained in:
bosiraphael
2024-03-22 18:44:14 +01:00
committed by GitHub
parent 1a763263c9
commit 96cad2accd
29 changed files with 580 additions and 271 deletions

View File

@ -1,27 +0,0 @@
import { Participant } from 'src/modules/messaging/types/gmail-message';
import { getDomainNameFromHandle } from 'src/modules/messaging/utils/get-domain-name-from-handle.util';
import { WorkspaceMemberObjectMetadata } from 'src/modules/workspace-member/standard-objects/workspace-member.object-metadata';
import { ObjectRecord } from 'src/engine/workspace-manager/workspace-sync-metadata/types/object-record';
export function filterOutParticipantsFromCompanyOrWorkspace(
participants: Participant[],
selfHandle: string,
workspaceMembers: ObjectRecord<WorkspaceMemberObjectMetadata>[],
): Participant[] {
const selfDomainName = getDomainNameFromHandle(selfHandle);
const workspaceMembersMap = workspaceMembers.reduce(
(map, workspaceMember) => {
map[workspaceMember.userEmail] = true;
return map;
},
new Map<string, boolean>(),
);
return participants.filter(
(participant) =>
getDomainNameFromHandle(participant.handle) !== selfDomainName &&
!workspaceMembersMap[participant.handle],
);
}

View File

@ -1,19 +0,0 @@
import { uniq, uniqBy } from 'lodash';
import { Participant } from 'src/modules/messaging/types/gmail-message';
export function getUniqueParticipantsAndHandles(participants: Participant[]): {
uniqueParticipants: Participant[];
uniqueHandles: string[];
} {
if (participants.length === 0) {
return { uniqueParticipants: [], uniqueHandles: [] };
}
const uniqueHandles = uniq(
participants.map((participant) => participant.handle),
);
const uniqueParticipants = uniqBy(participants, 'handle');
return { uniqueParticipants, uniqueHandles };
}