mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-01 03:03:10 -06:00
Fix check
This commit is contained in:
parent
b4135c4bae
commit
84f8e675d4
|
|
@ -88,10 +88,7 @@ func (m1 *DeviceMessage) DeviceKeysEqual(m2 *DeviceMessage) (bool, error) {
|
||||||
if len(m1.KeyJSON) == 0 && len(m2.KeyJSON) == 0 {
|
if len(m1.KeyJSON) == 0 && len(m2.KeyJSON) == 0 {
|
||||||
return true, nil // both are empty
|
return true, nil // both are empty
|
||||||
}
|
}
|
||||||
if len(m1.KeyJSON) == 0 || len(m2.KeyJSON) == 0 {
|
return bytes.Equal(m1.KeyJSON, m2.KeyJSON) && len(m1.KeyJSON) > 0, nil
|
||||||
return false, nil // only one is empty
|
|
||||||
}
|
|
||||||
return bytes.Equal(m1.KeyJSON, m2.KeyJSON), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeviceKeys represents a set of device keys for a single device
|
// DeviceKeys represents a set of device keys for a single device
|
||||||
|
|
|
||||||
|
|
@ -718,8 +718,8 @@ func emitDeviceKeyChanges(producer KeyChangeProducer, existing, new []api.Device
|
||||||
for _, existingKey := range existing {
|
for _, existingKey := range existing {
|
||||||
// Do not treat the absence of keys as equal, or else we will not emit key changes
|
// Do not treat the absence of keys as equal, or else we will not emit key changes
|
||||||
// when users delete devices which never had a key to begin with as both KeyJSONs are nil.
|
// when users delete devices which never had a key to begin with as both KeyJSONs are nil.
|
||||||
// if bytes.Equal(existingKey.KeyJSON, newKey.KeyJSON) && len(existingKey.KeyJSON) > 0 {
|
|
||||||
if equal, err := existingKey.DeviceKeysEqual(&newKey); err != nil {
|
if equal, err := existingKey.DeviceKeysEqual(&newKey); err != nil {
|
||||||
|
// One of the keys was not a DeviceKeys or the user ID/device ID did not match.
|
||||||
continue
|
continue
|
||||||
} else if equal {
|
} else if equal {
|
||||||
exists = true
|
exists = true
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue