From 3b6a94f007a2afd519688622eafe601636675dd3 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Mon, 4 May 2020 11:30:02 +0100 Subject: [PATCH] Return incompatible room version error --- clientapi/jsonerror/jsonerror.go | 7 +++++++ federationapi/routing/join.go | 4 +--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/clientapi/jsonerror/jsonerror.go b/clientapi/jsonerror/jsonerror.go index 735de5bea..85e887aec 100644 --- a/clientapi/jsonerror/jsonerror.go +++ b/clientapi/jsonerror/jsonerror.go @@ -18,6 +18,7 @@ import ( "fmt" "net/http" + "github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/util" ) @@ -124,6 +125,12 @@ func GuestAccessForbidden(msg string) *MatrixError { return &MatrixError{"M_GUEST_ACCESS_FORBIDDEN", msg} } +// IncompatibleRoomVersion is an error which is returned when the client +// requests a room with a version that is unsupported. +func IncompatibleRoomVersion(roomVersion gomatrixserverlib.RoomVersion) *MatrixError { + return &MatrixError{"M_INCOMPATIBLE_ROOM_VERSION", string(roomVersion)} +} + // UnsupportedRoomVersion is an error which is returned when the client // requests a room with a version that is unsupported. func UnsupportedRoomVersion(msg string) *MatrixError { diff --git a/federationapi/routing/join.go b/federationapi/routing/join.go index 23f39ea46..e851cb086 100644 --- a/federationapi/routing/join.go +++ b/federationapi/routing/join.go @@ -62,9 +62,7 @@ func MakeJoin( if !remoteSupportsVersion { return util.JSONResponse{ Code: http.StatusBadRequest, - JSON: jsonerror.UnsupportedRoomVersion( - fmt.Sprintf("Joining server does not support room version %s", verRes.RoomVersion), - ), + JSON: jsonerror.IncompatibleRoomVersion(verRes.RoomVersion), } }