aboutsummaryrefslogtreecommitdiff
path: root/userapi
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2020-08-12 22:43:02 +0100
committerGitHub <noreply@github.com>2020-08-12 22:43:02 +0100
commit820c56c165ec8f0409d23cd151a7ff89fbe09ffa (patch)
tree2266b281e13fc971d56625f416d1e03979062c43 /userapi
parentd98ec12422c8498cf710bb34d2ed31f024aa1e15 (diff)
Fix more E2E sytests (#1265)
* WIP: Eagerly sync device lists on /user/keys/query requests Also notify servers when a user's device display name changes. Few caveats: - sytest `Device deletion propagates over federation` fails - `populateResponseWithDeviceKeysFromDatabase` is called from multiple goroutines and hence is unsafe. * Handle deleted devices correctly over federation
Diffstat (limited to 'userapi')
-rw-r--r--userapi/internal/api.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/userapi/internal/api.go b/userapi/internal/api.go
index f58c7113..05cecc1b 100644
--- a/userapi/internal/api.go
+++ b/userapi/internal/api.go
@@ -180,6 +180,27 @@ func (a *UserInternalAPI) PerformDeviceUpdate(ctx context.Context, req *api.Perf
util.GetLogger(ctx).WithError(err).Error("deviceDB.UpdateDevice failed")
return err
}
+ if req.DisplayName != nil && dev.DisplayName != *req.DisplayName {
+ // display name has changed: update the device key
+ var uploadRes keyapi.PerformUploadKeysResponse
+ a.KeyAPI.PerformUploadKeys(context.Background(), &keyapi.PerformUploadKeysRequest{
+ DeviceKeys: []keyapi.DeviceKeys{
+ {
+ DeviceID: dev.ID,
+ DisplayName: *req.DisplayName,
+ KeyJSON: nil,
+ UserID: dev.UserID,
+ },
+ },
+ OnlyDisplayNameUpdates: true,
+ }, &uploadRes)
+ if uploadRes.Error != nil {
+ return fmt.Errorf("Failed to update device key display name: %v", uploadRes.Error)
+ }
+ if len(uploadRes.KeyErrors) > 0 {
+ return fmt.Errorf("Failed to update device key display name, key errors: %+v", uploadRes.KeyErrors)
+ }
+ }
return nil
}