contact/company creations errors (#11540)
Seeing a couple of issues related to company creations in logs, I suspect this to be the root cause This should help a lot in all the support we have to do on email synchronisation
This commit is contained in:
@ -9,16 +9,20 @@ export function filterOutSelfAndContactsFromCompanyOrWorkspace(
|
||||
connectedAccount: ConnectedAccountWorkspaceEntity,
|
||||
workspaceMembers: WorkspaceMemberWorkspaceEntity[],
|
||||
): Contact[] {
|
||||
const selfDomainName = getDomainNameFromHandle(connectedAccount.handle);
|
||||
const selfDomainName = getDomainNameFromHandle(
|
||||
connectedAccount.handle,
|
||||
).toLowerCase();
|
||||
|
||||
const allHandles = [
|
||||
connectedAccount.handle,
|
||||
...(connectedAccount.handleAliases?.split(',') || []),
|
||||
connectedAccount.handle.toLowerCase(),
|
||||
...(connectedAccount.handleAliases?.split(',') || []).map((handle) =>
|
||||
handle.toLowerCase(),
|
||||
),
|
||||
];
|
||||
|
||||
const workspaceMembersMap = workspaceMembers.reduce(
|
||||
(map, workspaceMember) => {
|
||||
map[workspaceMember.userEmail] = true;
|
||||
map[workspaceMember.userEmail.toLowerCase()] = true;
|
||||
|
||||
return map;
|
||||
},
|
||||
@ -26,13 +30,13 @@ export function filterOutSelfAndContactsFromCompanyOrWorkspace(
|
||||
);
|
||||
|
||||
const isDifferentDomain = (contact: Contact, selfDomainName: string) =>
|
||||
getDomainNameFromHandle(contact.handle) !== selfDomainName;
|
||||
getDomainNameFromHandle(contact.handle).toLowerCase() !== selfDomainName;
|
||||
|
||||
return contacts.filter(
|
||||
(contact) =>
|
||||
(isDifferentDomain(contact, selfDomainName) ||
|
||||
!isWorkDomain(selfDomainName)) &&
|
||||
!workspaceMembersMap[contact.handle] &&
|
||||
!allHandles.includes(contact.handle),
|
||||
!workspaceMembersMap[contact.handle.toLowerCase()] &&
|
||||
!allHandles.includes(contact.handle.toLowerCase()),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user