feat: getContactLidAndPhone (#3673)

* Add method getContactLidOrPhone

* Add method getContactLidOrPhone

* Add method getContactLidOrPhone

* Add method getContactLidOrPhone

* Add method getContactLidOrPhone

* Add method getContactLidOrPhone

Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>

* Add method getContactLidOrPhone

Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>

* Add method getContactLidOrPhone

Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>

* Add method getContactLidOrPhone

* Delete docs/index.html

* Delete docs/Client.html

* Create Client.html

* Create index.html

* Update to return the object

* Update to return an object

* Update Client.js to return both objects lid and phone

* Update Client.js to return both objects lid and phone

* Update src/Client.js

Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>

* Update src/Client.js

Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>

* Update index.d.ts

Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>

* refactor: rename function name for more clarity

* Change accept and return Array

* Change accept and return Array

---------

Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>
This commit is contained in:
BenyFilho 2025-07-29 11:39:39 -03:00 • committed by GitHub
commit 81fb154a9f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 25 additions and 0 deletions

View file

@ -2180,6 +2180,28 @@ class Client extends EventEmitter {
return await window.Store.AddressbookContactUtils.deleteContactAction(phoneNumber);
}, phoneNumber);
}
/**
* Get lid and phone number for multiple users
* @param {string[]} userIds - Array of user IDs
* @returns {Promise<Array<{ lid: string, pn: string }>>}
*/
async getContactLidAndPhone(userIds) {
return await this.pupPage.evaluate((userIds) => {
!Array.isArray(userIds) && (userIds = [userIds]);
return userIds.map(userId => {
const wid = window.Store.WidFactory.createWid(userId);
const isLid = wid.server === 'lid';
const lid = isLid ? wid : window.Store.LidUtils.getCurrentLid(wid);
const phone = isLid ? window.Store.LidUtils.getPhoneNumber(wid) : wid;
return {
lid: lid._serialized,
pn: phone._serialized
};
});
}, userIds);
}
}
module.exports = Client;