Delete a version of key backup. Version must not be empty. If the key backup was previously deleted, will return 200 OK. Implements DELETE /_matrix/client/r0/room_keys/version/{version}
(req *http.Request, userAPI userapi.ClientUserAPI, device *userapi.Device, version string)
| 160 | // Delete a version of key backup. Version must not be empty. If the key backup was previously deleted, will return 200 OK. |
| 161 | // Implements DELETE /_matrix/client/r0/room_keys/version/{version} |
| 162 | func DeleteKeyBackupVersion(req *http.Request, userAPI userapi.ClientUserAPI, device *userapi.Device, version string) util.JSONResponse { |
| 163 | var performKeyBackupResp userapi.PerformKeyBackupResponse |
| 164 | if err := userAPI.PerformKeyBackup(req.Context(), &userapi.PerformKeyBackupRequest{ |
| 165 | UserID: device.UserID, |
| 166 | Version: version, |
| 167 | DeleteBackup: true, |
| 168 | }, &performKeyBackupResp); err != nil { |
| 169 | return jsonerror.InternalServerError() |
| 170 | } |
| 171 | if performKeyBackupResp.Error != "" { |
| 172 | if performKeyBackupResp.BadInput { |
| 173 | return util.JSONResponse{ |
| 174 | Code: 400, |
| 175 | JSON: jsonerror.InvalidArgumentValue(performKeyBackupResp.Error), |
| 176 | } |
| 177 | } |
| 178 | return util.ErrorResponse(fmt.Errorf("PerformKeyBackup: %s", performKeyBackupResp.Error)) |
| 179 | } |
| 180 | if !performKeyBackupResp.Exists { |
| 181 | return util.JSONResponse{ |
| 182 | Code: 404, |
| 183 | JSON: jsonerror.NotFound("backup version not found"), |
| 184 | } |
| 185 | } |
| 186 | // Unclear what the 200 body should be |
| 187 | return util.JSONResponse{ |
| 188 | Code: 200, |
| 189 | JSON: keyBackupVersionCreateResponse{ |
| 190 | Version: performKeyBackupResp.Version, |
| 191 | }, |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | // Upload a bunch of session keys for a given `version`. |
| 196 | func UploadBackupKeys( |
no test coverage detected