diff options
author | S7evinK <2353100+S7evinK@users.noreply.github.com> | 2022-02-22 17:34:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-22 16:34:53 +0000 |
commit | 41dc651b25019b9ecc2338ff2ebec202066aaf21 (patch) | |
tree | 42b882c685a2677198b2fe5313edff5c65dc2853 /keyserver | |
parent | cfff1b0aaafc68efbac27f366360667983f7696a (diff) |
Send device update to local users if remote display name changes (#2215)
* Send device_list update to satisfy sytest
* Fix build issue from merged in change
Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
Diffstat (limited to 'keyserver')
-rw-r--r-- | keyserver/internal/device_list_update.go | 6 | ||||
-rw-r--r-- | keyserver/internal/internal.go | 8 |
2 files changed, 9 insertions, 5 deletions
diff --git a/keyserver/internal/device_list_update.go b/keyserver/internal/device_list_update.go index b208f0ce..974d0196 100644 --- a/keyserver/internal/device_list_update.go +++ b/keyserver/internal/device_list_update.go @@ -224,7 +224,7 @@ func (u *DeviceListUpdater) update(ctx context.Context, event gomatrixserverlib. }).Info("DeviceListUpdater.Update") // if we haven't missed anything update the database and notify users - if exists { + if exists || event.Deleted { k := event.Keys if event.Deleted { k = nil @@ -267,7 +267,7 @@ func (u *DeviceListUpdater) update(ctx context.Context, event gomatrixserverlib. return false, fmt.Errorf("failed to store remote device keys for %s (%s): %w", event.UserID, event.DeviceID, err) } - if err = emitDeviceKeyChanges(u.producer, existingKeys, keys); err != nil { + if err = emitDeviceKeyChanges(u.producer, existingKeys, keys, false); err != nil { return false, fmt.Errorf("failed to produce device key changes for %s (%s): %w", event.UserID, event.DeviceID, err) } return false, nil @@ -473,7 +473,7 @@ func (u *DeviceListUpdater) updateDeviceList(res *gomatrixserverlib.RespUserDevi if err != nil { return fmt.Errorf("failed to mark device list as fresh: %w", err) } - err = emitDeviceKeyChanges(u.producer, existingKeys, keys) + err = emitDeviceKeyChanges(u.producer, existingKeys, keys, false) if err != nil { return fmt.Errorf("failed to emit key changes for fresh device list: %w", err) } diff --git a/keyserver/internal/internal.go b/keyserver/internal/internal.go index dc3c404b..0a8bef95 100644 --- a/keyserver/internal/internal.go +++ b/keyserver/internal/internal.go @@ -648,7 +648,7 @@ func (a *KeyInternalAPI) uploadLocalDeviceKeys(ctx context.Context, req *api.Per } return } - err = emitDeviceKeyChanges(a.Producer, existingKeys, keysToStore) + err = emitDeviceKeyChanges(a.Producer, existingKeys, keysToStore, req.OnlyDisplayNameUpdates) if err != nil { util.GetLogger(ctx).Errorf("Failed to emitDeviceKeyChanges: %s", err) } @@ -710,7 +710,11 @@ func (a *KeyInternalAPI) uploadOneTimeKeys(ctx context.Context, req *api.Perform } -func emitDeviceKeyChanges(producer KeyChangeProducer, existing, new []api.DeviceMessage) error { +func emitDeviceKeyChanges(producer KeyChangeProducer, existing, new []api.DeviceMessage, onlyUpdateDisplayName bool) error { + // if we only want to update the display names, we can skip the checks below + if onlyUpdateDisplayName { + return producer.ProduceKeyChanges(new) + } // find keys in new that are not in existing var keysAdded []api.DeviceMessage for _, newKey := range new { |