aboutsummaryrefslogtreecommitdiff
path: root/federationapi
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2020-04-24 16:30:25 +0100
committerGitHub <noreply@github.com>2020-04-24 16:30:25 +0100
commit3ab8ebf6b8fbc813bfb3e0e0735e76a69a8ed2dd (patch)
treea5e83730ac7c8e7f8b53b102c4a426a1ce930ba8 /federationapi
parentbe558f02aa956cfff51c5dfcf57575b46254b0db (diff)
More invite support (#979)
* Update gomatixserverlib * Try to build invite stripped state if not given to us * SendInvite improvements * Transpose invite_room_state into invite_state.events for sync API * Remove syncapi debugging output * Use RespInviteV2 * Update gomatrixserverlib * Send the invite event as a normal roomserver event too, for incorporating into room (should this be done by the roomserver automatically for invite inputs?) * Federation sender use invite_room_state, room server try to insert membership state * Check supported room versions on the invite endpoint * Prevent roomserver query API from trying to handle requests for stub rooms * Adding a nolint * Replace IsRoomStub with RoomNIDExcludingStubs, fix query API to use that instead * Review comments
Diffstat (limited to 'federationapi')
-rw-r--r--federationapi/routing/invite.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/federationapi/routing/invite.go b/federationapi/routing/invite.go
index 4b367e00..064abe7e 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{
@@ -90,6 +102,8 @@ func Invite(
httpReq.Context(),
signedEvent.Headered(inviteReq.RoomVersion()),
inviteReq.InviteRoomState(),
+ event.Origin(),
+ nil,
); err != nil {
util.GetLogger(httpReq.Context()).WithError(err).Error("producer.SendInvite failed")
return jsonerror.InternalServerError()
@@ -99,6 +113,6 @@ func Invite(
// the other servers in the room that we have been invited.
return util.JSONResponse{
Code: http.StatusOK,
- JSON: gomatrixserverlib.RespInvite{Event: signedEvent},
+ JSON: gomatrixserverlib.RespInviteV2{Event: signedEvent},
}
}