Return 400 M_NOT_JSON for empty request body in /rooms/:roomID/:action

Fixes #767

Signed-off-by: Priydarshi Singh dryairship@gmail.com
This commit is contained in:
Priydarshi Singh 2020-01-01 00:46:47 +05:30
parent 5741235833
commit d6011fb4d4

View file

@ -46,6 +46,14 @@ func SendMembership(
producer *producers.RoomserverProducer,
) util.JSONResponse {
var body threepid.MembershipRequest
if req.Body == http.NoBody {
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.NotJSON("No request body"),
}
}
if reqErr := httputil.UnmarshalJSONRequest(req, &body); reqErr != nil {
return *reqErr
}