diff --git a/packages/calling/src/Contacts/ContactsClient.test.ts b/packages/calling/src/Contacts/ContactsClient.test.ts index 404023aaba4..b882d31979e 100644 --- a/packages/calling/src/Contacts/ContactsClient.test.ts +++ b/packages/calling/src/Contacts/ContactsClient.test.ts @@ -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, }, ]); }); diff --git a/packages/calling/src/Contacts/ContactsClient.ts b/packages/calling/src/Contacts/ContactsClient.ts index efb2add327e..0245c7461e3 100644 --- a/packages/calling/src/Contacts/ContactsClient.ts +++ b/packages/calling/src/Contacts/ContactsClient.ts @@ -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; @@ -300,6 +312,7 @@ export class ContactsClient implements IContacts { ownerId, phoneNumbers, sipAddresses, + resolved: true, }; finalContactList.push(cloudContact); diff --git a/packages/calling/src/Contacts/types.ts b/packages/calling/src/Contacts/types.ts index 443f0149034..8a0b01b3568 100644 --- a/packages/calling/src/Contacts/types.ts +++ b/packages/calling/src/Contacts/types.ts @@ -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 {