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,
|
connectedAccount: ConnectedAccountWorkspaceEntity,
|
||||||
workspaceMembers: WorkspaceMemberWorkspaceEntity[],
|
workspaceMembers: WorkspaceMemberWorkspaceEntity[],
|
||||||
): Contact[] {
|
): Contact[] {
|
||||||
const selfDomainName = getDomainNameFromHandle(connectedAccount.handle);
|
const selfDomainName = getDomainNameFromHandle(
|
||||||
|
connectedAccount.handle,
|
||||||
|
).toLowerCase();
|
||||||
|
|
||||||
const allHandles = [
|
const allHandles = [
|
||||||
connectedAccount.handle,
|
connectedAccount.handle.toLowerCase(),
|
||||||
...(connectedAccount.handleAliases?.split(',') || []),
|
...(connectedAccount.handleAliases?.split(',') || []).map((handle) =>
|
||||||
|
handle.toLowerCase(),
|
||||||
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
const workspaceMembersMap = workspaceMembers.reduce(
|
const workspaceMembersMap = workspaceMembers.reduce(
|
||||||
(map, workspaceMember) => {
|
(map, workspaceMember) => {
|
||||||
map[workspaceMember.userEmail] = true;
|
map[workspaceMember.userEmail.toLowerCase()] = true;
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
},
|
},
|
||||||
@ -26,13 +30,13 @@ export function filterOutSelfAndContactsFromCompanyOrWorkspace(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const isDifferentDomain = (contact: Contact, selfDomainName: string) =>
|
const isDifferentDomain = (contact: Contact, selfDomainName: string) =>
|
||||||
getDomainNameFromHandle(contact.handle) !== selfDomainName;
|
getDomainNameFromHandle(contact.handle).toLowerCase() !== selfDomainName;
|
||||||
|
|
||||||
return contacts.filter(
|
return contacts.filter(
|
||||||
(contact) =>
|
(contact) =>
|
||||||
(isDifferentDomain(contact, selfDomainName) ||
|
(isDifferentDomain(contact, selfDomainName) ||
|
||||||
!isWorkDomain(selfDomainName)) &&
|
!isWorkDomain(selfDomainName)) &&
|
||||||
!workspaceMembersMap[contact.handle] &&
|
!workspaceMembersMap[contact.handle.toLowerCase()] &&
|
||||||
!allHandles.includes(contact.handle),
|
!allHandles.includes(contact.handle.toLowerCase()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user