Skip to content

Commit

Permalink
feat(contacts): add the resolved field to contacts (#3848)
Browse files Browse the repository at this point in the history
  • Loading branch information
sreenara authored Sep 23, 2024
1 parent 15d6e91 commit 1eaba02
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
41 changes: 41 additions & 0 deletions packages/calling/src/Contacts/ContactsClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,47 @@ describe('ContactClient Tests', () => {
ownerId: 'ownerId',
phoneNumbers: undefined,
sipAddresses: undefined,
resolved: true,
},
]);
});

it("test resolveContacts function when contactsDataMap list doesn't match resolved list", () => {
const mockContact = {
firstName: 'Jane',
lastName: 'Doe',
contactId: 'janeDoe',
};

const contact = contactClient['resolveCloudContacts'](
{userId: mockContactMinimum, janeDoe: mockContact},
mockSCIMMinListResponse.body
);

expect(contact).toEqual([
{
firstName: 'Jane',
lastName: 'Doe',
contactId: 'janeDoe',
resolved: false,
},
{
avatarURL: '',
avatarUrlDomain: undefined,
contactId: 'userId',
contactType: 'CLOUD',
department: undefined,
displayName: undefined,
emails: undefined,
encryptionKeyUrl: 'kms://cisco.com/keys/dcf18f9d-155e-44ff-ad61-c8a69b7103ab',
firstName: undefined,
groups: ['1561977e-3443-4ccf-a591-69686275d7d2'],
lastName: undefined,
manager: undefined,
ownerId: 'ownerId',
phoneNumbers: undefined,
sipAddresses: undefined,
resolved: true,
},
]);
});
Expand Down
13 changes: 13 additions & 0 deletions packages/calling/src/Contacts/ContactsClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,20 @@ export class ContactsClient implements IContacts {
method: 'resolveCloudContacts',
};
const finalContactList: Contact[] = [];
const resolvedList: string[] = [];

try {
inputList.Resources.forEach((item) => {
resolvedList.push(item.id);
});

Object.values(contactsDataMap).forEach((item) => {
const isResolved = resolvedList.some((listItem) => listItem === item.contactId);
if (!isResolved) {
finalContactList.push({...item, resolved: false});
}
});

for (let n = 0; n < inputList.Resources.length; n += 1) {
const filteredContact = inputList.Resources[n];
const {displayName, emails, phoneNumbers, photos} = filteredContact;
Expand Down Expand Up @@ -300,6 +312,7 @@ export class ContactsClient implements IContacts {
ownerId,
phoneNumbers,
sipAddresses,
resolved: true,
};

finalContactList.push(cloudContact);
Expand Down
4 changes: 2 additions & 2 deletions packages/calling/src/Contacts/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ export type Contact = {
*/
sipAddresses?: URIAddress[];
/**
* This represents the job title of the contact.
* This field indicates whether the contact was resolved successfully.
*/
title?: string;
resolved: boolean;
};

export enum GroupType {
Expand Down

0 comments on commit 1eaba02

Please sign in to comment.