aboutsummaryrefslogtreecommitdiff
path: root/userapi
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2021-08-18 12:07:09 +0100
committerGitHub <noreply@github.com>2021-08-18 12:07:09 +0100
commit614e67280defda4a9156f620f2751e3ef136da81 (patch)
treeee1f1ce88768d0179b2dbd73ea40877cc507e55b /userapi
parent1bee1ae2048051b52bc5b5084808a0418c0def04 (diff)
Delete device keys/signatures from key server when deleting devices (#1979)
* Delete device keys/signatures from key server when deleting device from user API * Move loop to within database transaction * Don't fall over deleting no rows
Diffstat (limited to 'userapi')
-rw-r--r--userapi/internal/api.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/userapi/internal/api.go b/userapi/internal/api.go
index a2bc8ecf..518edef4 100644
--- a/userapi/internal/api.go
+++ b/userapi/internal/api.go
@@ -145,6 +145,18 @@ func (a *UserInternalAPI) PerformDeviceDeletion(ctx context.Context, req *api.Pe
if err != nil {
return err
}
+ // Ask the keyserver to delete device keys and signatures for those devices
+ deleteReq := &keyapi.PerformDeleteKeysRequest{
+ UserID: req.UserID,
+ }
+ for _, keyID := range req.DeviceIDs {
+ deleteReq.KeyIDs = append(deleteReq.KeyIDs, gomatrixserverlib.KeyID(keyID))
+ }
+ deleteRes := &keyapi.PerformDeleteKeysResponse{}
+ a.KeyAPI.PerformDeleteKeys(ctx, deleteReq, deleteRes)
+ if err := deleteRes.Error; err != nil {
+ return fmt.Errorf("a.KeyAPI.PerformDeleteKeys: %w", err)
+ }
// create empty device keys and upload them to delete what was once there and trigger device list changes
return a.deviceListUpdate(req.UserID, deletedDeviceIDs)
}