Return the correct error codes for v6 invite JSON violations (#1440)

* Return the correct error codes for v6 invite JSON violations

* Update sytest-whitelist
This commit is contained in:
Neil Alexander 2020-09-24 17:16:59 +01:00 committed by GitHub
parent 3013ade84f
commit 6fbf89a166
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 4 deletions

View file

@ -138,7 +138,14 @@ func SendLeave(
// Decode the event JSON from the request.
event, err := gomatrixserverlib.NewEventFromUntrustedJSON(request.Content(), verRes.RoomVersion)
if err != nil {
switch err.(type) {
case gomatrixserverlib.BadJSONError:
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.BadJSON(err.Error()),
}
case nil:
default:
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.NotJSON("The request body could not be decoded into valid JSON. " + err.Error()),