mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-01 22:02:46 +00:00
Only emit key changes which are different from what we had before (#1279)
We did this already for local `/keys/upload` but didn't for remote `/users/devices`. This meant any resyncs would spam produce events, hammering disk i/o and spamming the logs.
This commit is contained in:
parent
a5a85c6a11
commit
02a8515e99
3 changed files with 26 additions and 4 deletions
|
@ -505,7 +505,7 @@ func (a *KeyInternalAPI) uploadLocalDeviceKeys(ctx context.Context, req *api.Per
|
|||
}
|
||||
return
|
||||
}
|
||||
err = a.emitDeviceKeyChanges(existingKeys, keysToStore)
|
||||
err = emitDeviceKeyChanges(a.Producer, existingKeys, keysToStore)
|
||||
if err != nil {
|
||||
util.GetLogger(ctx).Errorf("Failed to emitDeviceKeyChanges: %s", err)
|
||||
}
|
||||
|
@ -550,7 +550,7 @@ func (a *KeyInternalAPI) uploadOneTimeKeys(ctx context.Context, req *api.Perform
|
|||
|
||||
}
|
||||
|
||||
func (a *KeyInternalAPI) emitDeviceKeyChanges(existing, new []api.DeviceMessage) error {
|
||||
func emitDeviceKeyChanges(producer KeyChangeProducer, existing, new []api.DeviceMessage) error {
|
||||
// find keys in new that are not in existing
|
||||
var keysAdded []api.DeviceMessage
|
||||
for _, newKey := range new {
|
||||
|
@ -567,7 +567,7 @@ func (a *KeyInternalAPI) emitDeviceKeyChanges(existing, new []api.DeviceMessage)
|
|||
keysAdded = append(keysAdded, newKey)
|
||||
}
|
||||
}
|
||||
return a.Producer.ProduceKeyChanges(keysAdded)
|
||||
return producer.ProduceKeyChanges(keysAdded)
|
||||
}
|
||||
|
||||
func appendDisplayNames(existing, new []api.DeviceMessage) []api.DeviceMessage {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue