From c4d9b374927309e327c19f1985ad65c3b78ab5ee Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 17 Jun 2020 13:54:47 +0100 Subject: [PATCH 1/2] add test --- sytest-whitelist | 1 + 1 file changed, 1 insertion(+) diff --git a/sytest-whitelist b/sytest-whitelist index 8f3d128d7..244cfe8cc 100644 --- a/sytest-whitelist +++ b/sytest-whitelist @@ -331,3 +331,4 @@ Can download file 'ascii' Can download file 'name with spaces' Can download file 'name;with;semicolons' Can download specifying a different ASCII file name +Inbound /v1/send_join rejects joins from other servers From 38053a5bb7af9bba522225fc62bee73d363bff85 Mon Sep 17 00:00:00 2001 From: Kegsay Date: Wed, 17 Jun 2020 13:55:55 +0100 Subject: [PATCH 2/2] Do not wrap send_join errors on /v1/send_join (#1143) * Do not wrap v1 send_join errors in [code, body] * Don't wrap errors --- federationapi/routing/routing.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/federationapi/routing/routing.go b/federationapi/routing/routing.go index 649a43c66..645f397de 100644 --- a/federationapi/routing/routing.go +++ b/federationapi/routing/routing.go @@ -18,6 +18,7 @@ import ( "net/http" "github.com/gorilla/mux" + "github.com/matrix-org/dendrite/clientapi/jsonerror" eduserverAPI "github.com/matrix-org/dendrite/eduserver/api" federationSenderAPI "github.com/matrix-org/dendrite/federationsender/api" "github.com/matrix-org/dendrite/internal/config" @@ -203,12 +204,20 @@ func Setup( res := SendJoin( httpReq, request, cfg, rsAPI, keys, roomID, eventID, ) + // not all responses get wrapped in [code, body] + var body interface{} + body = []interface{}{ + res.Code, res.JSON, + } + jerr, ok := res.JSON.(*jsonerror.MatrixError) + if ok { + body = jerr + } + return util.JSONResponse{ Headers: res.Headers, Code: res.Code, - JSON: []interface{}{ - res.Code, res.JSON, - }, + JSON: body, } }, )).Methods(http.MethodPut)