diff --git a/federationapi/routing/join.go b/federationapi/routing/join.go index 8dcd15333..a937120e4 100644 --- a/federationapi/routing/join.go +++ b/federationapi/routing/join.go @@ -28,6 +28,10 @@ import ( "github.com/matrix-org/util" ) +type JoinError struct { + Error interface{} +} + // MakeJoin implements the /make_join API func MakeJoin( httpReq *http.Request, @@ -224,7 +228,9 @@ func SendJoin( if verifyResults[0].Error != nil { return util.JSONResponse{ Code: http.StatusForbidden, - JSON: jsonerror.Forbidden("Signature check failed: " + verifyResults[0].Error.Error()), + JSON: JoinError{ + Error: jsonerror.Forbidden("Signature check failed: " + verifyResults[0].Error.Error()), + }, } } diff --git a/federationapi/routing/routing.go b/federationapi/routing/routing.go index 649a43c66..8db3ed5ca 100644 --- a/federationapi/routing/routing.go +++ b/federationapi/routing/routing.go @@ -203,12 +203,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.(JoinError) + if ok { + body = jerr.Error + } + return util.JSONResponse{ Headers: res.Headers, Code: res.Code, - JSON: []interface{}{ - res.Code, res.JSON, - }, + JSON: body, } }, )).Methods(http.MethodPut)