aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2020-06-17 13:55:55 +0100
committerGitHub <noreply@github.com>2020-06-17 13:55:55 +0100
commit38053a5bb7af9bba522225fc62bee73d363bff85 (patch)
tree4a2f292dc4fe56a40d7411db9e1f49656dbbfc5d
parentc4d9b374927309e327c19f1985ad65c3b78ab5ee (diff)
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
-rw-r--r--federationapi/routing/routing.go15
1 files 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)