mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-21 05:43:09 -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"
|
"github.com/matrix-org/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type JoinError struct {
|
||||||
|
Error interface{}
|
||||||
|
}
|
||||||
|
|
||||||
// MakeJoin implements the /make_join API
|
// MakeJoin implements the /make_join API
|
||||||
func MakeJoin(
|
func MakeJoin(
|
||||||
httpReq *http.Request,
|
httpReq *http.Request,
|
||||||
|
|
@ -224,7 +228,9 @@ func SendJoin(
|
||||||
if verifyResults[0].Error != nil {
|
if verifyResults[0].Error != nil {
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusForbidden,
|
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(
|
res := SendJoin(
|
||||||
httpReq, request, cfg, rsAPI, keys, roomID, eventID,
|
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{
|
return util.JSONResponse{
|
||||||
Headers: res.Headers,
|
Headers: res.Headers,
|
||||||
Code: res.Code,
|
Code: res.Code,
|
||||||
JSON: []interface{}{
|
JSON: body,
|
||||||
res.Code, res.JSON,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)).Methods(http.MethodPut)
|
)).Methods(http.MethodPut)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue