From 4f16b79e0cbc412cb97e74d436c4c23091da2b4e Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 24 Apr 2020 12:49:05 +0100 Subject: [PATCH] Check supported room versions on the invite endpoint --- federationapi/routing/invite.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/federationapi/routing/invite.go b/federationapi/routing/invite.go index 9fce46a09..064abe7e9 100644 --- a/federationapi/routing/invite.go +++ b/federationapi/routing/invite.go @@ -16,11 +16,13 @@ package routing import ( "encoding/json" + "fmt" "net/http" "github.com/matrix-org/dendrite/clientapi/jsonerror" "github.com/matrix-org/dendrite/clientapi/producers" "github.com/matrix-org/dendrite/common/config" + roomserverVersion "github.com/matrix-org/dendrite/roomserver/version" "github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/util" ) @@ -44,6 +46,16 @@ func Invite( } event := inviteReq.Event() + // Check that we can accept invites for this room version. + if _, err := roomserverVersion.SupportedRoomVersion(inviteReq.RoomVersion()); err != nil { + return util.JSONResponse{ + Code: http.StatusBadRequest, + JSON: jsonerror.UnsupportedRoomVersion( + fmt.Sprintf("Room version %q is not supported by this server.", inviteReq.RoomVersion()), + ), + } + } + // Check that the room ID is correct. if event.RoomID() != roomID { return util.JSONResponse{