mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-31 18:53: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 {
|
||||
return true, nil // both are empty
|
||||
}
|
||||
if len(m1.KeyJSON) == 0 || len(m2.KeyJSON) == 0 {
|
||||
return false, nil // only one is empty
|
||||
}
|
||||
return bytes.Equal(m1.KeyJSON, m2.KeyJSON), nil
|
||||
return bytes.Equal(m1.KeyJSON, m2.KeyJSON) && len(m1.KeyJSON) > 0, nil
|
||||
}
|
||||
|
||||
// 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 {
|
||||
// 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.
|
||||
// if bytes.Equal(existingKey.KeyJSON, newKey.KeyJSON) && len(existingKey.KeyJSON) > 0 {
|
||||
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
|
||||
} else if equal {
|
||||
exists = true
|
||||
|
|
|
|||
Loading…
Reference in a new issue