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
1 changed files with 48 additions and 28 deletions
|
|
@ -1144,4 +1144,26 @@ exports.LoadUtils = () => {
|
|||
const statuses = window.Store.Status.getModelsArray();
|
||||
return statuses.map(status => window.WWebJS.getStatusModel(status));
|
||||
};
|
||||
|
||||
window.WWebJS.enforceLidAndPnRetrieval = async (userId) => {
|
||||
const wid = window.Store.WidFactory.createWid(userId);
|
||||
const isLid = wid.server === 'lid';
|
||||
|
||||
let lid = isLid ? wid : window.Store.LidUtils.getCurrentLid(wid);
|
||||
let phone = isLid ? window.Store.LidUtils.getPhoneNumber(wid) : wid;
|
||||
|
||||
if (!isLid && !lid) {
|
||||
const queryResult = await window.Store.QueryExist(wid);
|
||||
if (!queryResult?.wid) return {};
|
||||
lid = window.Store.LidUtils.getCurrentLid(wid);
|
||||
}
|
||||
|
||||
if (isLid && !phone) {
|
||||
const queryResult = await window.Store.QueryExist(wid);
|
||||
if (!queryResult?.wid) return {};
|
||||
phone = window.Store.LidUtils.getPhoneNumber(wid);
|
||||
}
|
||||
|
||||
return { lid, phone };
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue