From 10514ebb63de09440d2412fac64210105d619632 Mon Sep 17 00:00:00 2001 From: Sumner Evans Date: Fri, 15 Apr 2022 09:01:08 -0600 Subject: [PATCH] config: add option to rate limit media creation Signed-off-by: Sumner Evans --- docs/usage/configuration/config_documentation.md | 13 +++++++++++++ synapse/config/ratelimiting.py | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/docs/usage/configuration/config_documentation.md b/docs/usage/configuration/config_documentation.md index 6601bba9f203..b4e06feeaedd 100644 --- a/docs/usage/configuration/config_documentation.md +++ b/docs/usage/configuration/config_documentation.md @@ -1731,6 +1731,19 @@ rc_third_party_invite: burst_count: 10 ``` --- +### `rc_media_create` + +This option ratelimits creation of MXC URIs via the `/_matrix/media/v1/create` +endpoint based on the account that's creating the media. Defaults to +`per_second: 10`, `burst_count: 50`. + +Example configuration: +```yaml +rc_media_create: + per_second: 10 + burst_count: 50 +``` +--- ### `rc_federation` Defines limits on federation requests. diff --git a/synapse/config/ratelimiting.py b/synapse/config/ratelimiting.py index a5514e70a21d..577d7d41cdd7 100644 --- a/synapse/config/ratelimiting.py +++ b/synapse/config/ratelimiting.py @@ -160,3 +160,9 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None: config.get("rc_third_party_invite", {}), defaults={"per_second": 0.0025, "burst_count": 5}, ) + + # Ratelimit create media requests: + self.rc_media_create = RatelimitSettings( + config.get("rc_media_create", {}), + defaults={"per_second": 10, "burst_count": 50}, + )