aboutsummaryrefslogtreecommitdiff
path: root/federationapi
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2020-06-04 10:53:39 +0100
committerGitHub <noreply@github.com>2020-06-04 10:53:39 +0100
commit8a6152ca70aa86df651db54efb3b1ec68ec9ec78 (patch)
treeb08e70cd3c92f24968be0a5477d285be0dcb80cd /federationapi
parente21d7d4bafb8c785e75369bebd5270cc67cb36d4 (diff)
Enable room version 6 (#1087)
* Return bad request on CS API /send if bad JSON * Return some more M_BAD_JSON in the right places * nolint because damnit gocyclo all I added was a type check for an error * Update gomatrixserverlib * Update gomatrixserverlib * Update sytest-whitelist * Update gomatrixserverlib * Update sytest-whitelist * NotJSON -> BadJSON
Diffstat (limited to 'federationapi')
-rw-r--r--federationapi/routing/join.go7
-rw-r--r--federationapi/routing/leave.go5
2 files changed, 11 insertions, 1 deletions
diff --git a/federationapi/routing/join.go b/federationapi/routing/join.go
index 617a6cab..5b4e8db3 100644
--- a/federationapi/routing/join.go
+++ b/federationapi/routing/join.go
@@ -102,6 +102,11 @@ func MakeJoin(
Code: http.StatusNotFound,
JSON: jsonerror.NotFound("Room does not exist"),
}
+ } else if e, ok := err.(gomatrixserverlib.BadJSONError); ok {
+ return util.JSONResponse{
+ Code: http.StatusBadRequest,
+ JSON: jsonerror.BadJSON(e.Error()),
+ }
} else if err != nil {
util.GetLogger(httpReq.Context()).WithError(err).Error("internal.BuildEvent failed")
return jsonerror.InternalServerError()
@@ -157,7 +162,7 @@ func SendJoin(
if err != nil {
return util.JSONResponse{
Code: http.StatusBadRequest,
- JSON: jsonerror.NotJSON("The request body could not be decoded into valid JSON. " + err.Error()),
+ JSON: jsonerror.BadJSON("The request body could not be decoded into valid JSON: " + err.Error()),
}
}
diff --git a/federationapi/routing/leave.go b/federationapi/routing/leave.go
index bd226d7e..62ca1145 100644
--- a/federationapi/routing/leave.go
+++ b/federationapi/routing/leave.go
@@ -76,6 +76,11 @@ func MakeLeave(
Code: http.StatusNotFound,
JSON: jsonerror.NotFound("Room does not exist"),
}
+ } else if e, ok := err.(gomatrixserverlib.BadJSONError); ok {
+ return util.JSONResponse{
+ Code: http.StatusBadRequest,
+ JSON: jsonerror.BadJSON(e.Error()),
+ }
} else if err != nil {
util.GetLogger(httpReq.Context()).WithError(err).Error("internal.BuildEvent failed")
return jsonerror.InternalServerError()