summaryrefslogtreecommitdiffstats
path: root/vendor/go.mau.fi
diff options
context:
space:
mode:
authorWim <wim@42.be>2022-05-02 00:10:54 +0200
committerGitHub <noreply@github.com>2022-05-02 00:10:54 +0200
commit81e6f75aa491c7bfa11780dd622587cf5fff3c8f (patch)
tree817bca1b4071842029af876ab622bfdcb0360cca /vendor/go.mau.fi
parent888c8b9a845866730485a3a88c27027d0960d521 (diff)
downloadmatterbridge-msglm-81e6f75aa491c7bfa11780dd622587cf5fff3c8f.tar.gz
matterbridge-msglm-81e6f75aa491c7bfa11780dd622587cf5fff3c8f.tar.bz2
matterbridge-msglm-81e6f75aa491c7bfa11780dd622587cf5fff3c8f.zip
Update dependencies (#1822)
Diffstat (limited to 'vendor/go.mau.fi')
-rw-r--r--vendor/go.mau.fi/whatsmeow/client.go1
-rw-r--r--vendor/go.mau.fi/whatsmeow/store/clientpayload.go2
-rw-r--r--vendor/go.mau.fi/whatsmeow/store/signal.go96
-rw-r--r--vendor/go.mau.fi/whatsmeow/store/sqlstore/container.go7
-rw-r--r--vendor/go.mau.fi/whatsmeow/store/store.go11
-rw-r--r--vendor/go.mau.fi/whatsmeow/types/events/events.go12
-rw-r--r--vendor/go.mau.fi/whatsmeow/upload.go2
7 files changed, 86 insertions, 45 deletions
diff --git a/vendor/go.mau.fi/whatsmeow/client.go b/vendor/go.mau.fi/whatsmeow/client.go
index 75054cea..2190e138 100644
--- a/vendor/go.mau.fi/whatsmeow/client.go
+++ b/vendor/go.mau.fi/whatsmeow/client.go
@@ -488,6 +488,7 @@ func (cli *Client) handlerQueueLoop(ctx context.Context) {
}
}
}
+
func (cli *Client) sendNode(node waBinary.Node) error {
cli.socketLock.RLock()
sock := cli.socket
diff --git a/vendor/go.mau.fi/whatsmeow/store/clientpayload.go b/vendor/go.mau.fi/whatsmeow/store/clientpayload.go
index 23b0f438..9a65f515 100644
--- a/vendor/go.mau.fi/whatsmeow/store/clientpayload.go
+++ b/vendor/go.mau.fi/whatsmeow/store/clientpayload.go
@@ -74,7 +74,7 @@ func (vc WAVersionContainer) ProtoAppVersion() *waProto.AppVersion {
}
// waVersion is the WhatsApp web client version
-var waVersion = WAVersionContainer{2, 2214, 9}
+var waVersion = WAVersionContainer{2, 2214, 12}
// waVersionHash is the md5 hash of a dot-separated waVersion
var waVersionHash [16]byte
diff --git a/vendor/go.mau.fi/whatsmeow/store/signal.go b/vendor/go.mau.fi/whatsmeow/store/signal.go
index 4c2a4e92..4c06ed4f 100644
--- a/vendor/go.mau.fi/whatsmeow/store/signal.go
+++ b/vendor/go.mau.fi/whatsmeow/store/signal.go
@@ -1,4 +1,4 @@
-// Copyright (c) 2021 Tulir Asokan
+// Copyright (c) 2022 Tulir Asokan
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -14,6 +14,8 @@ import (
"go.mau.fi/libsignal/serialize"
"go.mau.fi/libsignal/state/record"
"go.mau.fi/libsignal/state/store"
+
+ "go.mau.fi/whatsmeow/util/keys"
)
var SignalProtobufSerializer = serialize.NewProtoBufSerializer()
@@ -32,26 +34,33 @@ func (device *Device) GetLocalRegistrationId() uint32 {
}
func (device *Device) SaveIdentity(address *protocol.SignalAddress, identityKey *identity.Key) {
- err := device.Identities.PutIdentity(address.String(), identityKey.PublicKey().PublicKey())
- if err != nil {
- device.Log.Errorf("Failed to save identity of %s: %v", address.String(), err)
+ for i := 0; ; i++ {
+ err := device.Identities.PutIdentity(address.String(), identityKey.PublicKey().PublicKey())
+ if err == nil || !device.handleDatabaseError(i, err, "save identity of %s", address.String()) {
+ break
+ }
}
}
func (device *Device) IsTrustedIdentity(address *protocol.SignalAddress, identityKey *identity.Key) bool {
- isTrusted, err := device.Identities.IsTrustedIdentity(address.String(), identityKey.PublicKey().PublicKey())
- if err != nil {
- device.Log.Errorf("Failed to check if %s's identity is trusted: %v", address.String(), err)
+ for i := 0; ; i++ {
+ isTrusted, err := device.Identities.IsTrustedIdentity(address.String(), identityKey.PublicKey().PublicKey())
+ if err == nil || !device.handleDatabaseError(i, err, "check if %s's identity is trusted", address.String()) {
+ return isTrusted
+ }
}
- return isTrusted
}
func (device *Device) LoadPreKey(id uint32) *record.PreKey {
- preKey, err := device.PreKeys.GetPreKey(id)
- if err != nil {
- device.Log.Errorf("Failed to load prekey %d: %v", id, err)
- return nil
- } else if preKey == nil {
+ var preKey *keys.PreKey
+ for i := 0; ; i++ {
+ var err error
+ preKey, err = device.PreKeys.GetPreKey(id)
+ if err == nil || !device.handleDatabaseError(i, err, "load prekey %d", id) {
+ break
+ }
+ }
+ if preKey == nil {
return nil
}
return record.NewPreKey(preKey.KeyID, ecc.NewECKeyPair(
@@ -61,9 +70,11 @@ func (device *Device) LoadPreKey(id uint32) *record.PreKey {
}
func (device *Device) RemovePreKey(id uint32) {
- err := device.PreKeys.RemovePreKey(id)
- if err != nil {
- device.Log.Errorf("Failed to remove prekey %d: %v", id, err)
+ for i := 0; ; i++ {
+ err := device.PreKeys.RemovePreKey(id)
+ if err == nil || !device.handleDatabaseError(i, err, "remove prekey %d", id) {
+ break
+ }
}
}
@@ -76,11 +87,15 @@ func (device *Device) ContainsPreKey(preKeyID uint32) bool {
}
func (device *Device) LoadSession(address *protocol.SignalAddress) *record.Session {
- rawSess, err := device.Sessions.GetSession(address.String())
- if err != nil {
- device.Log.Errorf("Failed to load session with %s: %v", address.String(), err)
- return record.NewSession(SignalProtobufSerializer.Session, SignalProtobufSerializer.State)
- } else if rawSess == nil {
+ var rawSess []byte
+ for i := 0; ; i++ {
+ var err error
+ rawSess, err = device.Sessions.GetSession(address.String())
+ if err == nil || !device.handleDatabaseError(i, err, "load session with %s", address.String()) {
+ break
+ }
+ }
+ if rawSess == nil {
return record.NewSession(SignalProtobufSerializer.Session, SignalProtobufSerializer.State)
}
sess, err := record.NewSessionFromBytes(rawSess, SignalProtobufSerializer.Session, SignalProtobufSerializer.State)
@@ -96,18 +111,21 @@ func (device *Device) GetSubDeviceSessions(name string) []uint32 {
}
func (device *Device) StoreSession(address *protocol.SignalAddress, record *record.Session) {
- err := device.Sessions.PutSession(address.String(), record.Serialize())
- if err != nil {
- device.Log.Errorf("Failed to store session with %s: %v", address.String(), err)
+ for i := 0; ; i++ {
+ err := device.Sessions.PutSession(address.String(), record.Serialize())
+ if err == nil || !device.handleDatabaseError(i, err, "store session with %s", address.String()) {
+ return
+ }
}
}
func (device *Device) ContainsSession(remoteAddress *protocol.SignalAddress) bool {
- hasSession, err := device.Sessions.HasSession(remoteAddress.String())
- if err != nil {
- device.Log.Warnf("Failed to check if store has session for %s: %v", remoteAddress.String(), err)
+ for i := 0; ; i++ {
+ hasSession, err := device.Sessions.HasSession(remoteAddress.String())
+ if err == nil || !device.handleDatabaseError(i, err, "store has session for %s", remoteAddress.String()) {
+ return hasSession
+ }
}
- return hasSession
}
func (device *Device) DeleteSession(remoteAddress *protocol.SignalAddress) {
@@ -145,18 +163,24 @@ func (device *Device) RemoveSignedPreKey(signedPreKeyID uint32) {
}
func (device *Device) StoreSenderKey(senderKeyName *protocol.SenderKeyName, keyRecord *groupRecord.SenderKey) {
- err := device.SenderKeys.PutSenderKey(senderKeyName.GroupID(), senderKeyName.Sender().String(), keyRecord.Serialize())
- if err != nil {
- device.Log.Errorf("Failed to store sender key from %s for %s: %v", senderKeyName.Sender().String(), senderKeyName.GroupID(), err)
+ for i := 0; ; i++ {
+ err := device.SenderKeys.PutSenderKey(senderKeyName.GroupID(), senderKeyName.Sender().String(), keyRecord.Serialize())
+ if err == nil || !device.handleDatabaseError(i, err, "store sender key from %s", senderKeyName.Sender().String()) {
+ return
+ }
}
}
func (device *Device) LoadSenderKey(senderKeyName *protocol.SenderKeyName) *groupRecord.SenderKey {
- rawKey, err := device.SenderKeys.GetSenderKey(senderKeyName.GroupID(), senderKeyName.Sender().String())
- if err != nil {
- device.Log.Errorf("Failed to load sender key from %s for %s: %v", senderKeyName.Sender().String(), senderKeyName.GroupID(), err)
- return groupRecord.NewSenderKey(SignalProtobufSerializer.SenderKeyRecord, SignalProtobufSerializer.SenderKeyState)
- } else if rawKey == nil {
+ var rawKey []byte
+ for i := 0; ; i++ {
+ var err error
+ rawKey, err = device.SenderKeys.GetSenderKey(senderKeyName.GroupID(), senderKeyName.Sender().String())
+ if err == nil || !device.handleDatabaseError(i, err, "load sender key from %s for %s", senderKeyName.Sender().String(), senderKeyName.GroupID()) {
+ break
+ }
+ }
+ if rawKey == nil {
return groupRecord.NewSenderKey(SignalProtobufSerializer.SenderKeyRecord, SignalProtobufSerializer.SenderKeyState)
}
key, err := groupRecord.NewSenderKeyFromBytes(rawKey, SignalProtobufSerializer.SenderKeyRecord, SignalProtobufSerializer.SenderKeyState)
diff --git a/vendor/go.mau.fi/whatsmeow/store/sqlstore/container.go b/vendor/go.mau.fi/whatsmeow/store/sqlstore/container.go
index 30d91971..3150cfec 100644
--- a/vendor/go.mau.fi/whatsmeow/store/sqlstore/container.go
+++ b/vendor/go.mau.fi/whatsmeow/store/sqlstore/container.go
@@ -1,4 +1,4 @@
-// Copyright (c) 2021 Tulir Asokan
+// Copyright (c) 2022 Tulir Asokan
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -25,6 +25,8 @@ type Container struct {
db *sql.DB
dialect string
log waLog.Logger
+
+ DatabaseErrorHandler func(device *store.Device, action string, attemptIndex int, err error) (retry bool)
}
var _ store.DeviceContainer = (*Container)(nil)
@@ -89,6 +91,7 @@ type scannable interface {
func (c *Container) scanDevice(row scannable) (*store.Device, error) {
var device store.Device
+ device.DatabaseErrorHandler = c.DatabaseErrorHandler
device.Log = c.log
device.SignedPreKey = &keys.PreKey{}
var noisePriv, identityPriv, preKeyPriv, preKeySig []byte
@@ -192,6 +195,8 @@ func (c *Container) NewDevice() *store.Device {
Log: c.log,
Container: c,
+ DatabaseErrorHandler: c.DatabaseErrorHandler,
+
NoiseKey: keys.NewKeyPair(),
IdentityKey: keys.NewKeyPair(),
RegistrationID: mathRand.Uint32(),
diff --git a/vendor/go.mau.fi/whatsmeow/store/store.go b/vendor/go.mau.fi/whatsmeow/store/store.go
index 67fe38fa..19feeb7f 100644
--- a/vendor/go.mau.fi/whatsmeow/store/store.go
+++ b/vendor/go.mau.fi/whatsmeow/store/store.go
@@ -8,6 +8,7 @@
package store
import (
+ "fmt"
"time"
waProto "go.mau.fi/whatsmeow/binary/proto"
@@ -123,6 +124,16 @@ type Device struct {
Contacts ContactStore
ChatSettings ChatSettingsStore
Container DeviceContainer
+
+ DatabaseErrorHandler func(device *Device, action string, attemptIndex int, err error) (retry bool)
+}
+
+func (device *Device) handleDatabaseError(attemptIndex int, err error, action string, args ...interface{}) bool {
+ if device.DatabaseErrorHandler != nil {
+ return device.DatabaseErrorHandler(device, fmt.Sprintf(action, args...), attemptIndex, err)
+ }
+ device.Log.Errorf("Failed to %s: %v", fmt.Sprintf(action, args...), err)
+ return false
}
func (device *Device) Save() error {
diff --git a/vendor/go.mau.fi/whatsmeow/types/events/events.go b/vendor/go.mau.fi/whatsmeow/types/events/events.go
index 933969e2..01fc8dc9 100644
--- a/vendor/go.mau.fi/whatsmeow/types/events/events.go
+++ b/vendor/go.mau.fi/whatsmeow/types/events/events.go
@@ -117,10 +117,10 @@ func (tb *TemporaryBan) String() string {
type ConnectFailureReason int
const (
- ConnectFailureLoggedOut ConnectFailureReason = 401
- ConnectFailureTempBanned ConnectFailureReason = 402
- ConnectFailureBanned ConnectFailureReason = 403
- ConnectFailureUnknownLogout ConnectFailureReason = 406
+ ConnectFailureLoggedOut ConnectFailureReason = 401
+ ConnectFailureTempBanned ConnectFailureReason = 402
+ ConnectFailureMainDeviceGone ConnectFailureReason = 403
+ ConnectFailureUnknownLogout ConnectFailureReason = 406
ConnectFailureClientOutdated ConnectFailureReason = 405
ConnectFailureBadUserAgent ConnectFailureReason = 409
@@ -131,7 +131,7 @@ const (
var connectFailureReasonMessage = map[ConnectFailureReason]string{
ConnectFailureLoggedOut: "logged out from another device",
ConnectFailureTempBanned: "account temporarily banned",
- ConnectFailureBanned: "account banned from WhatsApp",
+ ConnectFailureMainDeviceGone: "primary device was logged out", // seems to happen for both bans and switching phones
ConnectFailureUnknownLogout: "logged out for unknown reason",
ConnectFailureClientOutdated: "client is out of date",
ConnectFailureBadUserAgent: "client user agent was rejected",
@@ -139,7 +139,7 @@ var connectFailureReasonMessage = map[ConnectFailureReason]string{
// IsLoggedOut returns true if the client should delete session data due to this connect failure.
func (cfr ConnectFailureReason) IsLoggedOut() bool {
- return cfr == ConnectFailureLoggedOut || cfr == ConnectFailureBanned || cfr == ConnectFailureUnknownLogout
+ return cfr == ConnectFailureLoggedOut || cfr == ConnectFailureMainDeviceGone || cfr == ConnectFailureUnknownLogout
}
// String returns the reason code and a short human-readable description of the error.
diff --git a/vendor/go.mau.fi/whatsmeow/upload.go b/vendor/go.mau.fi/whatsmeow/upload.go
index b3e71cc4..aa50926f 100644
--- a/vendor/go.mau.fi/whatsmeow/upload.go
+++ b/vendor/go.mau.fi/whatsmeow/upload.go
@@ -47,7 +47,7 @@ type UploadResponse struct {
// // you can also optionally add other fields like ContextInfo and JpegThumbnail here
//
// Url: &resp.URL,
-// DirectPath: &uploaded.DirectPath,
+// DirectPath: &resp.DirectPath,
// MediaKey: resp.MediaKey,
// FileEncSha256: resp.FileEncSHA256,
// FileSha256: resp.FileSha256,