From 08489381747299d175d3f9a3fd0052f2e29a2d0b Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 6 Aug 2018 00:06:11 +0300 Subject: [PATCH] Add option to change max body size for AS API ref tulir/mautrix-appservice-python#3 --- example-config.yaml | 3 +++ mautrix_telegram/__main__.py | 4 ++-- mautrix_telegram/config.py | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/example-config.yaml b/example-config.yaml index 167fda4b..5d855afd 100644 --- a/example-config.yaml +++ b/example-config.yaml @@ -17,6 +17,9 @@ appservice: # The hostname and port where this appservice should listen. hostname: 0.0.0.0 port: 8080 + # The maximum body size of appservice API requests (from the homeserver) in mebibytes + # Usually 1 is enough, but on high-traffic bridges you might need to increase this to avoid 413s + max_body_size: 1 # The full URI to the database. SQLite and Postgres are fully supported. # Other DBMSes supported by SQLAlchemy may or may not work. diff --git a/mautrix_telegram/__main__.py b/mautrix_telegram/__main__.py index b1768a8f..b2e2064b 100644 --- a/mautrix_telegram/__main__.py +++ b/mautrix_telegram/__main__.py @@ -86,7 +86,8 @@ appserv = AppService(config["homeserver.address"], config["homeserver.domain"], config["appservice.as_token"], config["appservice.hs_token"], config["appservice.bot_username"], log="mau.as", loop=loop, verify_ssl=config["homeserver.verify_ssl"], state_store=state_store, - real_user_content_key="net.maunium.telegram.puppet") + real_user_content_key="net.maunium.telegram.puppet", + aiohttp_params={"client_max_size": config["appservice.max_body_size"]}) context = Context(appserv, db_session, config, loop, session_container) @@ -101,7 +102,6 @@ if config["appservice.provisioning.enabled"]: provisioning_api.app) context.provisioning_api = provisioning_api - with appserv.run(config["appservice.hostname"], config["appservice.port"]) as start: init_db(db_session) init_abstract_user(context) diff --git a/mautrix_telegram/config.py b/mautrix_telegram/config.py index 122e49d8..15da6cfa 100644 --- a/mautrix_telegram/config.py +++ b/mautrix_telegram/config.py @@ -153,6 +153,7 @@ class Config(DictWithRecursion): copy("appservice.address") copy("appservice.hostname") copy("appservice.port") + copy("appservice.max_body_size") copy("appservice.database")