diff options
author | Till <2353100+S7evinK@users.noreply.github.com> | 2023-07-13 14:18:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-13 14:18:37 +0200 |
commit | f12982472c71b8daf3de682c2807989ee695d2cf (patch) | |
tree | 16dce5247f0b7cc2c9416b68edf3bfd212079d87 /syncapi/routing/routing.go | |
parent | 0df982a2e50021183fa478d99b2e463d512ff230 (diff) |
Tweaks around `/messages` (#3149)
Try to mitigate some issues with `/messages`
Diffstat (limited to 'syncapi/routing/routing.go')
-rw-r--r-- | syncapi/routing/routing.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/syncapi/routing/routing.go b/syncapi/routing/routing.go index 8542c0b7..a837e169 100644 --- a/syncapi/routing/routing.go +++ b/syncapi/routing/routing.go @@ -43,6 +43,7 @@ func Setup( cfg *config.SyncAPI, lazyLoadCache caching.LazyLoadCache, fts fulltext.Indexer, + rateLimits *httputil.RateLimits, ) { v1unstablemux := csMux.PathPrefix("/{apiversion:(?:v1|unstable)}/").Subrouter() v3mux := csMux.PathPrefix("/{apiversion:(?:r0|v3)}/").Subrouter() @@ -53,6 +54,10 @@ func Setup( }, httputil.WithAllowGuests())).Methods(http.MethodGet, http.MethodOptions) v3mux.Handle("/rooms/{roomID}/messages", httputil.MakeAuthAPI("room_messages", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse { + // not specced, but ensure we're rate limiting requests to this endpoint + if r := rateLimits.Limit(req, device); r != nil { + return *r + } vars, err := httputil.URLDecodeMapValues(mux.Vars(req)) if err != nil { return util.ErrorResponse(err) |