aboutsummaryrefslogtreecommitdiff
path: root/clientapi
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2020-06-26 12:51:54 +0100
committerGitHub <noreply@github.com>2020-06-26 12:51:54 +0100
commit164057a3be1e666d6fb68398d616da9a8a665a18 (patch)
tree7499dd5bad788f9d0b6881cdc84d49039020c002 /clientapi
parent9592d53364b573f9cd6ae045b98c49779429fa5f (diff)
Honour event size limits and return 413 (#1167)
Diffstat (limited to 'clientapi')
-rw-r--r--clientapi/routing/sendevent.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/clientapi/routing/sendevent.go b/clientapi/routing/sendevent.go
index d8936f75..aba5f0d5 100644
--- a/clientapi/routing/sendevent.go
+++ b/clientapi/routing/sendevent.go
@@ -157,6 +157,17 @@ func generateSendEvent(
Code: http.StatusBadRequest,
JSON: jsonerror.BadJSON(e.Error()),
}
+ } else if e, ok := err.(gomatrixserverlib.EventValidationError); ok {
+ if e.Code == gomatrixserverlib.EventValidationTooLarge {
+ return nil, &util.JSONResponse{
+ Code: http.StatusRequestEntityTooLarge,
+ JSON: jsonerror.BadJSON(e.Error()),
+ }
+ }
+ return nil, &util.JSONResponse{
+ Code: http.StatusBadRequest,
+ JSON: jsonerror.BadJSON(e.Error()),
+ }
} else if err != nil {
util.GetLogger(req.Context()).WithError(err).Error("eventutil.BuildEvent failed")
resErr := jsonerror.InternalServerError()