aboutsummaryrefslogtreecommitdiff
path: root/clientapi/routing/admin.go
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2022-10-31 09:13:28 +0000
committerNeil Alexander <neilalexander@users.noreply.github.com>2022-10-31 09:13:28 +0000
commitf10c6f26e51e278ffe46f1267d6b188186a6b90e (patch)
tree5dea86427e3070d487c3f09ada90bd3825877ae4 /clientapi/routing/admin.go
parent69aff372f3e0ac5d98292e1e5382b66b162037ea (diff)
Add `/_dendrite/admin/downloadState/{serverName}/{roomID}` admin endpoint
Diffstat (limited to 'clientapi/routing/admin.go')
-rw-r--r--clientapi/routing/admin.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/clientapi/routing/admin.go b/clientapi/routing/admin.go
index 69bca13b..9088f771 100644
--- a/clientapi/routing/admin.go
+++ b/clientapi/routing/admin.go
@@ -191,3 +191,43 @@ func AdminMarkAsStale(req *http.Request, cfg *config.ClientAPI, keyAPI api.Clien
JSON: struct{}{},
}
}
+
+func AdminDownloadState(req *http.Request, cfg *config.ClientAPI, device *userapi.Device, rsAPI roomserverAPI.ClientRoomserverAPI) util.JSONResponse {
+ vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
+ if err != nil {
+ return util.ErrorResponse(err)
+ }
+ roomID, ok := vars["roomID"]
+ if !ok {
+ return util.JSONResponse{
+ Code: http.StatusBadRequest,
+ JSON: jsonerror.MissingArgument("Expecting room ID."),
+ }
+ }
+ serverName, ok := vars["serverName"]
+ if !ok {
+ return util.JSONResponse{
+ Code: http.StatusBadRequest,
+ JSON: jsonerror.MissingArgument("Expecting remote server name."),
+ }
+ }
+ res := &roomserverAPI.PerformAdminDownloadStateResponse{}
+ if err := rsAPI.PerformAdminDownloadState(
+ req.Context(),
+ &roomserverAPI.PerformAdminDownloadStateRequest{
+ UserID: device.UserID,
+ RoomID: roomID,
+ ServerName: gomatrixserverlib.ServerName(serverName),
+ },
+ res,
+ ); err != nil {
+ return jsonerror.InternalAPIError(req.Context(), err)
+ }
+ if err := res.Error; err != nil {
+ return err.JSONResponse()
+ }
+ return util.JSONResponse{
+ Code: 200,
+ JSON: map[string]interface{}{},
+ }
+}