aboutsummaryrefslogtreecommitdiff
path: root/clientapi/routing/routing.go
diff options
context:
space:
mode:
Diffstat (limited to 'clientapi/routing/routing.go')
-rw-r--r--clientapi/routing/routing.go42
1 files changed, 41 insertions, 1 deletions
diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go
index f370b4f8..ec90b80d 100644
--- a/clientapi/routing/routing.go
+++ b/clientapi/routing/routing.go
@@ -48,7 +48,8 @@ import (
// applied:
// nolint: gocyclo
func Setup(
- publicAPIMux, synapseAdminRouter *mux.Router, cfg *config.ClientAPI,
+ publicAPIMux, synapseAdminRouter, dendriteAdminRouter *mux.Router,
+ cfg *config.ClientAPI,
rsAPI roomserverAPI.RoomserverInternalAPI,
asAPI appserviceAPI.AppServiceQueryAPI,
userAPI userapi.UserInternalAPI,
@@ -119,6 +120,45 @@ func Setup(
).Methods(http.MethodGet, http.MethodPost, http.MethodOptions)
}
+ dendriteAdminRouter.Handle("/admin/evacuateRoom/{roomID}",
+ httputil.MakeAuthAPI("admin_evacuate_room", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse {
+ if device.AccountType != userapi.AccountTypeAdmin {
+ return util.JSONResponse{
+ Code: http.StatusForbidden,
+ JSON: jsonerror.Forbidden("This API can only be used by admin users."),
+ }
+ }
+ 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."),
+ }
+ }
+ res := &roomserverAPI.PerformAdminEvacuateRoomResponse{}
+ rsAPI.PerformAdminEvacuateRoom(
+ req.Context(),
+ &roomserverAPI.PerformAdminEvacuateRoomRequest{
+ RoomID: roomID,
+ },
+ res,
+ )
+ if err := res.Error; err != nil {
+ return err.JSONResponse()
+ }
+ return util.JSONResponse{
+ Code: 200,
+ JSON: map[string]interface{}{
+ "affected": res.Affected,
+ },
+ }
+ }),
+ ).Methods(http.MethodGet, http.MethodOptions)
+
// server notifications
if cfg.Matrix.ServerNotices.Enabled {
logrus.Info("Enabling server notices at /_synapse/admin/v1/send_server_notice")