From 82189cbde45225d6c8793018343f265894ac8e23 Mon Sep 17 00:00:00 2001 From: Hugh Nimmo-Smith Date: Fri, 6 Jun 2025 11:48:49 +0100 Subject: Export RatelimitOverride from ModuleApi (#18513) --- synapse/module_api/callbacks/ratelimit_callbacks.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'synapse/module_api/callbacks/ratelimit_callbacks.py') diff --git a/synapse/module_api/callbacks/ratelimit_callbacks.py b/synapse/module_api/callbacks/ratelimit_callbacks.py index ced721b407..64f9cc81e8 100644 --- a/synapse/module_api/callbacks/ratelimit_callbacks.py +++ b/synapse/module_api/callbacks/ratelimit_callbacks.py @@ -15,7 +15,8 @@ import logging from typing import TYPE_CHECKING, Awaitable, Callable, List, Optional -from synapse.storage.databases.main.room import RatelimitOverride +import attr + from synapse.util.async_helpers import delay_cancellation from synapse.util.metrics import Measure @@ -24,6 +25,17 @@ if TYPE_CHECKING: logger = logging.getLogger(__name__) + +@attr.s(auto_attribs=True) +class RatelimitOverride: + """Represents a ratelimit being overridden.""" + + per_second: float + """The number of actions that can be performed in a second. `0.0` means that ratelimiting is disabled.""" + burst_count: int + """How many actions that can be performed before being limited.""" + + GET_RATELIMIT_OVERRIDE_FOR_USER_CALLBACK = Callable[ [str, str], Awaitable[Optional[RatelimitOverride]] ] -- cgit 1.5.1