mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-01 03:03:10 -06:00
Check both directions of changes
This commit is contained in:
parent
3788512b0e
commit
812c3605c1
|
|
@ -192,13 +192,20 @@ func (a *KeyInternalAPI) PerformUploadDeviceKeys(ctx context.Context, req *api.P
|
||||||
|
|
||||||
// Check if anything actually changed compared to what we have in the database.
|
// Check if anything actually changed compared to what we have in the database.
|
||||||
changed := false
|
changed := false
|
||||||
for purpose, keydata := range toStore {
|
for _, purpose := range []gomatrixserverlib.CrossSigningKeyPurpose{
|
||||||
if _, ok := existingKeys[purpose]; !ok {
|
gomatrixserverlib.CrossSigningKeyPurposeMaster,
|
||||||
// A new key purpose has been specified that we didn't know before.
|
gomatrixserverlib.CrossSigningKeyPurposeSelfSigning,
|
||||||
|
gomatrixserverlib.CrossSigningKeyPurposeUserSigning,
|
||||||
|
} {
|
||||||
|
old, gotOld := existingKeys[purpose]
|
||||||
|
new, gotNew := toStore[purpose]
|
||||||
|
if gotOld != gotNew {
|
||||||
|
// A new key purpose has been specified that we didn't know before,
|
||||||
|
// or one has been removed.
|
||||||
changed = true
|
changed = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if !bytes.Equal(existingKeys[purpose], keydata) {
|
if !bytes.Equal(old, new) {
|
||||||
// One of the existing keys for a purpose we already knew about has
|
// One of the existing keys for a purpose we already knew about has
|
||||||
// changed.
|
// changed.
|
||||||
changed = true
|
changed = true
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue