Modify the auth data of a key backup. Version must not be empty. Request must contain a `keyBackupVersion` Implements PUT /_matrix/client/r0/room_keys/version/{version}
(req *http.Request, userAPI userapi.ClientUserAPI, device *userapi.Device, version string)
| 119 | // Modify the auth data of a key backup. Version must not be empty. Request must contain a `keyBackupVersion` |
| 120 | // Implements PUT /_matrix/client/r0/room_keys/version/{version} |
| 121 | func ModifyKeyBackupVersionAuthData(req *http.Request, userAPI userapi.ClientUserAPI, device *userapi.Device, version string) util.JSONResponse { |
| 122 | var kb keyBackupVersion |
| 123 | resErr := httputil.UnmarshalJSONRequest(req, &kb) |
| 124 | if resErr != nil { |
| 125 | return *resErr |
| 126 | } |
| 127 | var performKeyBackupResp userapi.PerformKeyBackupResponse |
| 128 | if err := userAPI.PerformKeyBackup(req.Context(), &userapi.PerformKeyBackupRequest{ |
| 129 | UserID: device.UserID, |
| 130 | Version: version, |
| 131 | AuthData: kb.AuthData, |
| 132 | Algorithm: kb.Algorithm, |
| 133 | }, &performKeyBackupResp); err != nil { |
| 134 | return jsonerror.InternalServerError() |
| 135 | } |
| 136 | if performKeyBackupResp.Error != "" { |
| 137 | if performKeyBackupResp.BadInput { |
| 138 | return util.JSONResponse{ |
| 139 | Code: 400, |
| 140 | JSON: jsonerror.InvalidArgumentValue(performKeyBackupResp.Error), |
| 141 | } |
| 142 | } |
| 143 | return util.ErrorResponse(fmt.Errorf("PerformKeyBackup: %s", performKeyBackupResp.Error)) |
| 144 | } |
| 145 | if !performKeyBackupResp.Exists { |
| 146 | return util.JSONResponse{ |
| 147 | Code: 404, |
| 148 | JSON: jsonerror.NotFound("backup version not found"), |
| 149 | } |
| 150 | } |
| 151 | // Unclear what the 200 body should be |
| 152 | return util.JSONResponse{ |
| 153 | Code: 200, |
| 154 | JSON: keyBackupVersionCreateResponse{ |
| 155 | Version: performKeyBackupResp.Version, |
| 156 | }, |
| 157 | } |
| 158 | } |
| 159 | |
| 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} |
no test coverage detected