From 048a24a1493ccc3423099fcae5fb4bdcf6d32d2c 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 | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/docs/usage/configuration/config_documentation.md b/docs/usage/configuration/config_documentation.md index 92e00c138086..2905da979b8d 100644 --- a/docs/usage/configuration/config_documentation.md +++ b/docs/usage/configuration/config_documentation.md @@ -1746,6 +1746,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 4efbaeac0d7f..b1fcaf71a3d1 100644 --- a/synapse/config/ratelimiting.py +++ b/synapse/config/ratelimiting.py @@ -204,3 +204,10 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None: "rc_third_party_invite", defaults={"per_second": 0.0025, "burst_count": 5}, ) + + # Ratelimit create media requests: + self.rc_media_create = RatelimitSettings.parse( + config, + "rc_media_create", + defaults={"per_second": 10, "burst_count": 50}, + )