Skip to content

Commit f123860

Browse files
committed
user: apply changes
1 parent 388dbda commit f123860

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

user.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ import (
1414
"slices"
1515
"strings"
1616

17-
"go.mau.fi/whatsmeow/store"
18-
1917
"google.golang.org/protobuf/proto"
2018

2119
waBinary "go.mau.fi/whatsmeow/binary"
2220
"go.mau.fi/whatsmeow/proto/waHistorySync"
2321
"go.mau.fi/whatsmeow/proto/waVnameCert"
22+
"go.mau.fi/whatsmeow/store"
2423
"go.mau.fi/whatsmeow/types"
2524
"go.mau.fi/whatsmeow/types/events"
2625
)
@@ -213,7 +212,7 @@ func (cli *Client) GetUserInfo(jids []types.JID) (map[types.JID]types.UserInfo,
213212
return nil, err
214213
}
215214
respData := make(map[types.JID]types.UserInfo, len(jids))
216-
mappings := make([]store.LIDMapping, len(jids))
215+
mappings := make([]store.LIDMapping, 0, len(jids))
217216
for _, child := range list.GetChildren() {
218217
jid, jidOK := child.Attrs["jid"].(types.JID)
219218
if child.Tag != "user" || !jidOK {
@@ -232,15 +231,21 @@ func (cli *Client) GetUserInfo(jids []types.JID) (map[types.JID]types.UserInfo,
232231
lidTag := child.GetChildByTag("lid")
233232
info.LID = lidTag.AttrGetter().OptionalJIDOrEmpty("val")
234233

235-
mappings = append(mappings, store.LIDMapping{PN: jid, LID: info.LID})
234+
if !info.LID.IsEmpty() {
235+
mappings = append(mappings, store.LIDMapping{PN: jid, LID: info.LID})
236+
}
236237

237238
if verifiedName != nil {
238239
cli.updateBusinessName(context.TODO(), jid, nil, verifiedName.Details.GetVerifiedName())
239240
}
240241
respData[jid] = info
241242
}
242243

243-
cli.Store.LIDs.PutManyLIDMappings(context.TODO(), mappings)
244+
err = cli.Store.LIDs.PutManyLIDMappings(context.TODO(), mappings)
245+
if err != nil {
246+
// not worth returning on the error, instead just post a log
247+
cli.Log.Errorf("Failed to place LID mappings from USync call")
248+
}
244249

245250
return respData, nil
246251
}

0 commit comments

Comments
 (0)