fix: enforce retrieval lid and phone for previously unknown contacts (#3702)

* fix: check existance if undefined

* fix: handle missing lid/phone in group participant resolution

* refactor: remove duplicated logic
This commit is contained in:
alechkos 2025-09-06 18:24:19 +03:00 • committed by GitHub
commit d077716315
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 48 additions and 28 deletions

View file

@ -2343,19 +2343,17 @@ class Client extends EventEmitter {
* @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 await this.pupPage.evaluate(async (userIds) => {
if (!Array.isArray(userIds)) userIds = [userIds];
return await Promise.all(userIds.map(async (userId) => {
const { lid, phone } = await window.WWebJS.enforceLidAndPnRetrieval(userId);
return {
lid: lid._serialized,
pn: phone._serialized
lid: lid?._serialized,
pn: phone?._serialized
};
});
}));
}, userIds);
}
}