summary refs log tree commit diff
path: root/synapse/api
diff options
context:
space:
mode:
authorOlivier Wilkinson (reivilibre) <oliverw@matrix.org>2022-10-28 15:59:51 +0100
committerOlivier Wilkinson (reivilibre) <oliverw@matrix.org>2022-10-28 15:59:51 +0100
commit1335367ca7014a2245f57c13d17885f35283270e (patch)
treef2e7a7904fc1aa832be1db950065d3ce7ffac2c2 /synapse/api
parentAdd docs for an empty `trusted_key_servers` config option (#13999) (diff)
parentTweak changelog (diff)
downloadsynapse-1335367ca7014a2245f57c13d17885f35283270e.tar.xz
Merge branch 'master' into develop
Diffstat (limited to 'synapse/api')
-rw-r--r--synapse/api/ratelimiting.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/synapse/api/ratelimiting.py b/synapse/api/ratelimiting.py
index 044c7d4926..511790c7c5 100644
--- a/synapse/api/ratelimiting.py
+++ b/synapse/api/ratelimiting.py
@@ -343,6 +343,7 @@ class RequestRatelimiter:
         requester: Requester,
         update: bool = True,
         is_admin_redaction: bool = False,
+        n_actions: int = 1,
     ) -> None:
         """Ratelimits requests.
 
@@ -355,6 +356,8 @@ class RequestRatelimiter:
             is_admin_redaction: Whether this is a room admin/moderator
                 redacting an event. If so then we may apply different
                 ratelimits depending on config.
+            n_actions: Multiplier for the number of actions to apply to the
+                rate limiter at once.
 
         Raises:
             LimitExceededError if the request should be ratelimited
@@ -383,7 +386,9 @@ class RequestRatelimiter:
         if is_admin_redaction and self.admin_redaction_ratelimiter:
             # If we have separate config for admin redactions, use a separate
             # ratelimiter as to not have user_ids clash
-            await self.admin_redaction_ratelimiter.ratelimit(requester, update=update)
+            await self.admin_redaction_ratelimiter.ratelimit(
+                requester, update=update, n_actions=n_actions
+            )
         else:
             # Override rate and burst count per-user
             await self.request_ratelimiter.ratelimit(
@@ -391,4 +396,5 @@ class RequestRatelimiter:
                 rate_hz=messages_per_second,
                 burst_count=burst_count,
                 update=update,
+                n_actions=n_actions,
             )