Skip to content

Commit 772b706

Browse files
Alexey Poliakovclaude
andcommitted
fix: resolve phone number for LID contacts in getContactModel
getUserid() returns LID user portion on migrated accounts, causing contact.number to be LID instead of phone. Now uses resolvedPhoneWid from LID resolution to override userid with actual phone number. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 03d6c8f commit 772b706

1 file changed

Lines changed: 11 additions & 18 deletions

File tree

src/util/Injected/Utils.js

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,31 +1036,17 @@ exports.LoadUtils = () => {
10361036
window.WWebJS.getContactModel = (contact) => {
10371037
let res = contact.serialize();
10381038

1039-
// Legacy: use ContactGetters.getUserid (old Store.ContactMethods approach)
1040-
try {
1041-
const ContactGetters = {
1042-
...window.require('WAWebContactGetters'),
1043-
...window.require('WAWebFrontendContactGetters'),
1044-
};
1045-
res.userid = ContactGetters.getUserid(contact);
1046-
} catch (e) {
1047-
// Legacy getUserid unavailable, fall through to new approach
1048-
}
1049-
1050-
// New: resolve via WID/LID phone resolution
1039+
let resolvedPhoneWid = null;
10511040
const wid = window
10521041
.require('WAWebWidFactory')
10531042
.createWidFromWidLike(contact.id);
10541043
if (wid.isLid()) {
10551044
try {
1056-
let phoneWid =
1045+
resolvedPhoneWid =
10571046
contact.phoneNumber ||
10581047
window.require('WAWebApiContact').getPhoneNumber(wid);
1059-
if (phoneWid) {
1060-
res.id = phoneWid;
1061-
if (!res.userid || String(res.userid).includes('@lid')) {
1062-
res.userid = phoneWid.user;
1063-
}
1048+
if (resolvedPhoneWid) {
1049+
res.id = resolvedPhoneWid;
10641050
}
10651051
} catch (e) {
10661052
// LID phone resolution failed, keep original values
@@ -1096,6 +1082,13 @@ exports.LoadUtils = () => {
10961082
res.isGroup = ContactMethods.getIsGroup(contact);
10971083
res.isWAContact = ContactMethods.getIsWAContact(contact);
10981084
res.userid = ContactMethods.getUserid(contact);
1085+
1086+
// getUserid returns LID user portion on migrated accounts,
1087+
// override with resolved phone number
1088+
if (resolvedPhoneWid?.user) {
1089+
res.userid = resolvedPhoneWid.user;
1090+
}
1091+
10991092
res.verifiedName = ContactMethods.getVerifiedName(contact);
11001093
res.verifiedLevel = ContactMethods.getVerifiedLevel(contact);
11011094
res.statusMute = ContactMethods.getStatusMute(contact);

0 commit comments

Comments
 (0)