aboutsummaryrefslogtreecommitdiff
path: root/userapi
diff options
context:
space:
mode:
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
}