summaryrefslogtreecommitdiffstats
path: root/vendor/go.mau.fi/whatsmeow/appstate/keys.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2022-06-11 23:07:42 +0200
committerGitHub <noreply@github.com>2022-06-11 23:07:42 +0200
commit8751fb4bb1eb7cd34ed63be9b3801b8aeac71a1d (patch)
tree601d2616b05b5b197bd2a3ae7cb245b1a0ea17e7 /vendor/go.mau.fi/whatsmeow/appstate/keys.go
parent3819062574ac7e4af6a562bf40a425469a7752fb (diff)
downloadmatterbridge-msglm-8751fb4bb1eb7cd34ed63be9b3801b8aeac71a1d.tar.gz
matterbridge-msglm-8751fb4bb1eb7cd34ed63be9b3801b8aeac71a1d.tar.bz2
matterbridge-msglm-8751fb4bb1eb7cd34ed63be9b3801b8aeac71a1d.zip
Update dependencies (#1841)
Diffstat (limited to 'vendor/go.mau.fi/whatsmeow/appstate/keys.go')
-rw-r--r--vendor/go.mau.fi/whatsmeow/appstate/keys.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/vendor/go.mau.fi/whatsmeow/appstate/keys.go b/vendor/go.mau.fi/whatsmeow/appstate/keys.go
index 30ecbcc4..ec19dc26 100644
--- a/vendor/go.mau.fi/whatsmeow/appstate/keys.go
+++ b/vendor/go.mau.fi/whatsmeow/appstate/keys.go
@@ -83,3 +83,36 @@ func (proc *Processor) getAppStateKey(keyID []byte) (keys ExpandedAppStateKeys,
}
return
}
+
+func (proc *Processor) GetMissingKeyIDs(pl *PatchList) [][]byte {
+ cache := make(map[string]bool)
+ var missingKeys [][]byte
+ checkMissing := func(keyID []byte) {
+ if keyID == nil {
+ return
+ }
+ stringKeyID := base64.RawStdEncoding.EncodeToString(keyID)
+ _, alreadyAdded := cache[stringKeyID]
+ if !alreadyAdded {
+ keyData, err := proc.Store.AppStateKeys.GetAppStateSyncKey(keyID)
+ if err != nil {
+ proc.Log.Warnf("Error fetching key %X while checking if it's missing: %v", keyID, err)
+ }
+ missing := keyData == nil && err == nil
+ cache[stringKeyID] = missing
+ if missing {
+ missingKeys = append(missingKeys, keyID)
+ }
+ }
+ }
+ if pl.Snapshot != nil {
+ checkMissing(pl.Snapshot.GetKeyId().GetId())
+ for _, record := range pl.Snapshot.GetRecords() {
+ checkMissing(record.GetKeyId().GetId())
+ }
+ }
+ for _, patch := range pl.Patches {
+ checkMissing(patch.GetKeyId().GetId())
+ }
+ return missingKeys
+}