mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-07-03 14:17:45 +00:00
Update dependencies (#1951)
This commit is contained in:
@ -74,7 +74,7 @@ func (vc WAVersionContainer) ProtoAppVersion() *waProto.ClientPayload_UserAgent_
|
||||
}
|
||||
|
||||
// waVersion is the WhatsApp web client version
|
||||
var waVersion = WAVersionContainer{2, 2245, 9}
|
||||
var waVersion = WAVersionContainer{2, 2301, 6}
|
||||
|
||||
// waVersionHash is the md5 hash of a dot-separated waVersion
|
||||
var waVersionHash [16]byte
|
||||
|
@ -126,6 +126,7 @@ func (c *Container) scanDevice(row scannable) (*store.Device, error) {
|
||||
device.Contacts = innerStore
|
||||
device.ChatSettings = innerStore
|
||||
device.MsgSecrets = innerStore
|
||||
device.PrivacyTokens = innerStore
|
||||
device.Container = c
|
||||
device.Initialized = true
|
||||
|
||||
@ -240,6 +241,7 @@ func (c *Container) PutDevice(device *store.Device) error {
|
||||
device.Contacts = innerStore
|
||||
device.ChatSettings = innerStore
|
||||
device.MsgSecrets = innerStore
|
||||
device.PrivacyTokens = innerStore
|
||||
device.Initialized = true
|
||||
}
|
||||
return err
|
||||
|
@ -706,7 +706,7 @@ func (s *SQLStore) PutMessageSecrets(inserts []store.MessageSecretInsert) (err e
|
||||
return fmt.Errorf("failed to begin transaction: %w", err)
|
||||
}
|
||||
for _, insert := range inserts {
|
||||
_, err = s.db.Exec(putMsgSecret, s.JID, insert.Chat.ToNonAD(), insert.Sender.ToNonAD(), insert.ID, insert.Secret)
|
||||
_, err = tx.Exec(putMsgSecret, s.JID, insert.Chat.ToNonAD(), insert.Sender.ToNonAD(), insert.ID, insert.Secret)
|
||||
}
|
||||
err = tx.Commit()
|
||||
if err != nil {
|
||||
@ -727,3 +727,42 @@ func (s *SQLStore) GetMessageSecret(chat, sender types.JID, id types.MessageID)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
const (
|
||||
putPrivacyTokens = `
|
||||
INSERT INTO whatsmeow_privacy_tokens (our_jid, their_jid, token, timestamp)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
ON CONFLICT (our_jid, their_jid) DO UPDATE SET token=EXCLUDED.token, timestamp=EXCLUDED.timestamp
|
||||
`
|
||||
getPrivacyToken = `SELECT token, timestamp FROM whatsmeow_privacy_tokens WHERE our_jid=$1 AND their_jid=$2`
|
||||
)
|
||||
|
||||
func (s *SQLStore) PutPrivacyTokens(tokens ...store.PrivacyToken) error {
|
||||
args := make([]any, 1+len(tokens)*3)
|
||||
placeholders := make([]string, len(tokens))
|
||||
args[0] = s.JID
|
||||
for i, token := range tokens {
|
||||
args[i*3+1] = token.User.ToNonAD().String()
|
||||
args[i*3+2] = token.Token
|
||||
args[i*3+3] = token.Timestamp.Unix()
|
||||
placeholders[i] = fmt.Sprintf("($1, $%d, $%d, $%d)", i*3+2, i*3+3, i*3+4)
|
||||
}
|
||||
query := strings.ReplaceAll(putPrivacyTokens, "($1, $2, $3, $4)", strings.Join(placeholders, ","))
|
||||
_, err := s.db.Exec(query, args...)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *SQLStore) GetPrivacyToken(user types.JID) (*store.PrivacyToken, error) {
|
||||
var token store.PrivacyToken
|
||||
token.User = user.ToNonAD()
|
||||
var ts int64
|
||||
err := s.db.QueryRow(getPrivacyToken, s.JID, token.User).Scan(&token.Token, &ts)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, nil
|
||||
} else if err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
token.Timestamp = time.Unix(ts, 0)
|
||||
return &token, nil
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ type upgradeFunc func(*sql.Tx, *Container) error
|
||||
//
|
||||
// This may be of use if you want to manage the database fully manually, but in most cases you
|
||||
// should just call Container.Upgrade to let the library handle everything.
|
||||
var Upgrades = [...]upgradeFunc{upgradeV1, upgradeV2, upgradeV3}
|
||||
var Upgrades = [...]upgradeFunc{upgradeV1, upgradeV2, upgradeV3, upgradeV4}
|
||||
|
||||
func (c *Container) getVersion() (int, error) {
|
||||
_, err := c.db.Exec("CREATE TABLE IF NOT EXISTS whatsmeow_version (version INTEGER)")
|
||||
@ -260,3 +260,14 @@ func upgradeV3(tx *sql.Tx, container *Container) error {
|
||||
)`)
|
||||
return err
|
||||
}
|
||||
|
||||
func upgradeV4(tx *sql.Tx, container *Container) error {
|
||||
_, err := tx.Exec(`CREATE TABLE whatsmeow_privacy_tokens (
|
||||
our_jid TEXT,
|
||||
their_jid TEXT,
|
||||
token bytea NOT NULL,
|
||||
timestamp BIGINT NOT NULL,
|
||||
PRIMARY KEY (our_jid, their_jid)
|
||||
)`)
|
||||
return err
|
||||
}
|
||||
|
34
vendor/go.mau.fi/whatsmeow/store/store.go
vendored
34
vendor/go.mau.fi/whatsmeow/store/store.go
vendored
@ -112,6 +112,17 @@ type MsgSecretStore interface {
|
||||
GetMessageSecret(chat, sender types.JID, id types.MessageID) ([]byte, error)
|
||||
}
|
||||
|
||||
type PrivacyToken struct {
|
||||
User types.JID
|
||||
Token []byte
|
||||
Timestamp time.Time
|
||||
}
|
||||
|
||||
type PrivacyTokenStore interface {
|
||||
PutPrivacyTokens(tokens ...PrivacyToken) error
|
||||
GetPrivacyToken(user types.JID) (*PrivacyToken, error)
|
||||
}
|
||||
|
||||
type Device struct {
|
||||
Log waLog.Logger
|
||||
|
||||
@ -127,17 +138,18 @@ type Device struct {
|
||||
BusinessName string
|
||||
PushName string
|
||||
|
||||
Initialized bool
|
||||
Identities IdentityStore
|
||||
Sessions SessionStore
|
||||
PreKeys PreKeyStore
|
||||
SenderKeys SenderKeyStore
|
||||
AppStateKeys AppStateSyncKeyStore
|
||||
AppState AppStateStore
|
||||
Contacts ContactStore
|
||||
ChatSettings ChatSettingsStore
|
||||
MsgSecrets MsgSecretStore
|
||||
Container DeviceContainer
|
||||
Initialized bool
|
||||
Identities IdentityStore
|
||||
Sessions SessionStore
|
||||
PreKeys PreKeyStore
|
||||
SenderKeys SenderKeyStore
|
||||
AppStateKeys AppStateSyncKeyStore
|
||||
AppState AppStateStore
|
||||
Contacts ContactStore
|
||||
ChatSettings ChatSettingsStore
|
||||
MsgSecrets MsgSecretStore
|
||||
PrivacyTokens PrivacyTokenStore
|
||||
Container DeviceContainer
|
||||
|
||||
DatabaseErrorHandler func(device *Device, action string, attemptIndex int, err error) (retry bool)
|
||||
}
|
||||
|
Reference in New Issue
Block a user