From 38053a5bb7af9bba522225fc62bee73d363bff85 Mon Sep 17 00:00:00 2001 From: Kegsay Date: Wed, 17 Jun 2020 13:55:55 +0100 Subject: 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 649a43c6..645f397d 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) -- cgit v1.2.3