aboutsummaryrefslogtreecommitdiff
path: root/roomserver/inthttp
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2020-09-24 16:18:13 +0100
committerGitHub <noreply@github.com>2020-09-24 16:18:13 +0100
commit3013ade84f65f7d255523d0beb7b721804c12ced (patch)
treeee4a3f2f4e2a6c76b7e92cd658a94894c98932c6 /roomserver/inthttp
parenta6700331cee70a3ca04c834efdc68cc2ef63947d (diff)
Reject make_join for empty rooms (#1439)
* Sanity-check room version on RS event input * Update gomatrixserverlib * Reject make_join when no room members are left * Revert some changes from wrong branch * Distinguish between room not existing and room being abandoned on this server * nolint
Diffstat (limited to 'roomserver/inthttp')
-rw-r--r--roomserver/inthttp/client.go14
-rw-r--r--roomserver/inthttp/server.go14
2 files changed, 28 insertions, 0 deletions
diff --git a/roomserver/inthttp/client.go b/roomserver/inthttp/client.go
index f2510c75..3dd3edaf 100644
--- a/roomserver/inthttp/client.go
+++ b/roomserver/inthttp/client.go
@@ -38,6 +38,7 @@ const (
RoomserverQueryEventsByIDPath = "/roomserver/queryEventsByID"
RoomserverQueryMembershipForUserPath = "/roomserver/queryMembershipForUser"
RoomserverQueryMembershipsForRoomPath = "/roomserver/queryMembershipsForRoom"
+ RoomserverQueryServerJoinedToRoomPath = "/roomserver/queryServerJoinedToRoomPath"
RoomserverQueryServerAllowedToSeeEventPath = "/roomserver/queryServerAllowedToSeeEvent"
RoomserverQueryMissingEventsPath = "/roomserver/queryMissingEvents"
RoomserverQueryStateAndAuthChainPath = "/roomserver/queryStateAndAuthChain"
@@ -312,6 +313,19 @@ func (h *httpRoomserverInternalAPI) QueryMembershipsForRoom(
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
+// QueryMembershipsForRoom implements RoomserverQueryAPI
+func (h *httpRoomserverInternalAPI) QueryServerJoinedToRoom(
+ ctx context.Context,
+ request *api.QueryServerJoinedToRoomRequest,
+ response *api.QueryServerJoinedToRoomResponse,
+) error {
+ span, ctx := opentracing.StartSpanFromContext(ctx, "QueryServerJoinedToRoom")
+ defer span.Finish()
+
+ apiURL := h.roomserverURL + RoomserverQueryServerJoinedToRoomPath
+ return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
+}
+
// QueryServerAllowedToSeeEvent implements RoomserverQueryAPI
func (h *httpRoomserverInternalAPI) QueryServerAllowedToSeeEvent(
ctx context.Context,
diff --git a/roomserver/inthttp/server.go b/roomserver/inthttp/server.go
index 8ffa9cf9..c7e541dd 100644
--- a/roomserver/inthttp/server.go
+++ b/roomserver/inthttp/server.go
@@ -168,6 +168,20 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
}),
)
internalAPIMux.Handle(
+ RoomserverQueryServerJoinedToRoomPath,
+ httputil.MakeInternalAPI("queryServerJoinedToRoom", func(req *http.Request) util.JSONResponse {
+ var request api.QueryServerJoinedToRoomRequest
+ var response api.QueryServerJoinedToRoomResponse
+ if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
+ return util.ErrorResponse(err)
+ }
+ if err := r.QueryServerJoinedToRoom(req.Context(), &request, &response); err != nil {
+ return util.ErrorResponse(err)
+ }
+ return util.JSONResponse{Code: http.StatusOK, JSON: &response}
+ }),
+ )
+ internalAPIMux.Handle(
RoomserverQueryServerAllowedToSeeEventPath,
httputil.MakeInternalAPI("queryServerAllowedToSeeEvent", func(req *http.Request) util.JSONResponse {
var request api.QueryServerAllowedToSeeEventRequest