summaryrefslogtreecommitdiffstats
path: root/vendor/go.mau.fi/whatsmeow/user.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2022-06-25 00:36:16 +0200
committerGitHub <noreply@github.com>2022-06-25 00:36:16 +0200
commit4649876956ab944d2a9ea8fc98c75dc8a9f5ef08 (patch)
tree0f32da8e492cabd8eca53de319e287e6c4791c5e /vendor/go.mau.fi/whatsmeow/user.go
parent5604d140e3bbf5c8f6c414b1427145a0c4e36bb4 (diff)
downloadmatterbridge-msglm-4649876956ab944d2a9ea8fc98c75dc8a9f5ef08.tar.gz
matterbridge-msglm-4649876956ab944d2a9ea8fc98c75dc8a9f5ef08.tar.bz2
matterbridge-msglm-4649876956ab944d2a9ea8fc98c75dc8a9f5ef08.zip
Update dependencies (#1851)
Diffstat (limited to 'vendor/go.mau.fi/whatsmeow/user.go')
-rw-r--r--vendor/go.mau.fi/whatsmeow/user.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/vendor/go.mau.fi/whatsmeow/user.go b/vendor/go.mau.fi/whatsmeow/user.go
index bbddd405..eadb6d6e 100644
--- a/vendor/go.mau.fi/whatsmeow/user.go
+++ b/vendor/go.mau.fi/whatsmeow/user.go
@@ -133,7 +133,7 @@ func (cli *Client) GetUserInfo(jids []types.JID) (map[types.JID]types.UserInfo,
info.PictureID, _ = child.GetChildByTag("picture").Attrs["id"].(string)
info.Devices = parseDeviceList(jid.User, child.GetChildByTag("devices"))
if verifiedName != nil {
- cli.updateBusinessName(jid, verifiedName.Details.GetVerifiedName())
+ cli.updateBusinessName(jid, nil, verifiedName.Details.GetVerifiedName())
}
respData[jid] = info
}
@@ -262,13 +262,21 @@ func (cli *Client) updatePushName(user types.JID, messageInfo *types.MessageInfo
}
}
-func (cli *Client) updateBusinessName(user types.JID, name string) {
+func (cli *Client) updateBusinessName(user types.JID, messageInfo *types.MessageInfo, name string) {
if cli.Store.Contacts == nil {
return
}
- err := cli.Store.Contacts.PutBusinessName(user, name)
+ changed, previousName, err := cli.Store.Contacts.PutBusinessName(user, name)
if err != nil {
cli.Log.Errorf("Failed to save business name of %s in device store: %v", user, err)
+ } else if changed {
+ cli.Log.Debugf("Business name of %s changed from %s to %s, dispatching event", user, previousName, name)
+ cli.dispatchEvent(&events.BusinessName{
+ JID: user,
+ Message: messageInfo,
+ OldBusinessName: previousName,
+ NewBusinessName: name,
+ })
}
}
@@ -280,6 +288,10 @@ func parseVerifiedName(businessNode waBinary.Node) (*types.VerifiedName, error)
if !ok {
return nil, nil
}
+ return parseVerifiedNameContent(verifiedNameNode)
+}
+
+func parseVerifiedNameContent(verifiedNameNode waBinary.Node) (*types.VerifiedName, error) {
rawCert, ok := verifiedNameNode.Content.([]byte)
if !ok {
return nil, nil