diff options
author | Wim <wim@42.be> | 2023-01-28 22:57:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-28 22:57:53 +0100 |
commit | 880586bac42817ffcfea5d9f746f503fa29915b8 (patch) | |
tree | a89374cba6f88975f12316ec8d1b8aa1d4c6ba79 /vendor/go.mau.fi/whatsmeow/client.go | |
parent | eac2a8c8dc831f946970d327e2a80b26b0684255 (diff) | |
download | matterbridge-msglm-880586bac42817ffcfea5d9f746f503fa29915b8.tar.gz matterbridge-msglm-880586bac42817ffcfea5d9f746f503fa29915b8.tar.bz2 matterbridge-msglm-880586bac42817ffcfea5d9f746f503fa29915b8.zip |
Update dependencies (#1951)
Diffstat (limited to 'vendor/go.mau.fi/whatsmeow/client.go')
-rw-r--r-- | vendor/go.mau.fi/whatsmeow/client.go | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/vendor/go.mau.fi/whatsmeow/client.go b/vendor/go.mau.fi/whatsmeow/client.go index 4a862bd3..3f832c94 100644 --- a/vendor/go.mau.fi/whatsmeow/client.go +++ b/vendor/go.mau.fi/whatsmeow/client.go @@ -114,11 +114,18 @@ type Client struct { // If it returns false, the accepting will be cancelled and the retry receipt will be ignored. PreRetryCallback func(receipt *events.Receipt, id types.MessageID, retryCount int, msg *waProto.Message) bool + // PrePairCallback is called before pairing is completed. If it returns false, the pairing will be cancelled and + // the client will disconnect. + PrePairCallback func(jid types.JID, platform, businessName string) bool + // Should untrusted identity errors be handled automatically? If true, the stored identity and existing signal // sessions will be removed on untrusted identity errors, and an events.IdentityChange will be dispatched. // If false, decrypting a message from untrusted devices will fail. AutoTrustIdentity bool + // Should SubscribePresence return an error if no privacy token is stored for the user? + ErrorOnSubscribePresenceWithoutToken bool + uniqueID string idCounter uint32 @@ -250,6 +257,14 @@ func (cli *Client) closeSocketWaitChan() { cli.socketLock.Unlock() } +func (cli *Client) getOwnID() types.JID { + id := cli.Store.ID + if id == nil { + return types.EmptyJID + } + return *id +} + func (cli *Client) WaitForConnection(timeout time.Duration) bool { timeoutChan := time.After(timeout) cli.socketLock.RLock() @@ -392,7 +407,8 @@ func (cli *Client) unlockedDisconnect() { // Note that this will not emit any events. The LoggedOut event is only used for external logouts // (triggered by the user from the main device or by WhatsApp servers). func (cli *Client) Logout() error { - if cli.Store.ID == nil { + ownID := cli.getOwnID() + if ownID.IsEmpty() { return ErrNotLoggedIn } _, err := cli.sendIQ(infoQuery{ @@ -402,7 +418,7 @@ func (cli *Client) Logout() error { Content: []waBinary.Node{{ Tag: "remove-companion-device", Attrs: waBinary.Attrs{ - "jid": *cli.Store.ID, + "jid": ownID, "reason": "user_initiated", }, }}, @@ -600,7 +616,10 @@ func (cli *Client) ParseWebMessage(chatJID types.JID, webMsg *waProto.WebMessage } var err error if info.IsFromMe { - info.Sender = cli.Store.ID.ToNonAD() + info.Sender = cli.getOwnID().ToNonAD() + if info.Sender.IsEmpty() { + return nil, ErrNotLoggedIn + } } else if chatJID.Server == types.DefaultUserServer { info.Sender = chatJID } else if webMsg.GetParticipant() != "" { |