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:
parent
54a77cf254
commit
d077716315
3 changed files with 48 additions and 28 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue