mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-20 13:23:22 -06:00
Do not wrap v1 send_join errors in [code, body]
This commit is contained in:
parent
e09d24e732
commit
f3bf6eb9f2
|
|
@ -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()),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue