summary refs log tree commit diff
path: root/synapse/api
diff options
context:
space:
mode:
authorNeil Johnson <neil@matrix.org>2019-10-24 11:48:46 +0100
committerRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2019-10-24 11:48:46 +0100
commit2794b79052f96b8103ce2b710959853313a82e90 (patch)
treec7741a1e807878cba3a13d7fe90f79e0dc308db4 /synapse/api
parentCleanup extra quotes from IDEs (#6236) (diff)
downloadsynapse-2794b79052f96b8103ce2b710959853313a82e90.tar.xz
Option to suppress resource exceeded alerting (#6173)
The expected use case is to suppress MAU limiting on small instances
Diffstat (limited to 'synapse/api')
-rw-r--r--synapse/api/auth.py12
-rw-r--r--synapse/api/constants.py7
2 files changed, 16 insertions, 3 deletions
diff --git a/synapse/api/auth.py b/synapse/api/auth.py

index cd347fbe1b..53f3bb0fa8 100644 --- a/synapse/api/auth.py +++ b/synapse/api/auth.py
@@ -25,7 +25,13 @@ from twisted.internet import defer import synapse.logging.opentracing as opentracing import synapse.types from synapse import event_auth -from synapse.api.constants import EventTypes, JoinRules, Membership, UserTypes +from synapse.api.constants import ( + EventTypes, + JoinRules, + LimitBlockingTypes, + Membership, + UserTypes, +) from synapse.api.errors import ( AuthError, Codes, @@ -726,7 +732,7 @@ class Auth(object): self.hs.config.hs_disabled_message, errcode=Codes.RESOURCE_LIMIT_EXCEEDED, admin_contact=self.hs.config.admin_contact, - limit_type=self.hs.config.hs_disabled_limit_type, + limit_type=LimitBlockingTypes.HS_DISABLED, ) if self.hs.config.limit_usage_by_mau is True: assert not (user_id and threepid) @@ -759,5 +765,5 @@ class Auth(object): "Monthly Active User Limit Exceeded", admin_contact=self.hs.config.admin_contact, errcode=Codes.RESOURCE_LIMIT_EXCEEDED, - limit_type="monthly_active_user", + limit_type=LimitBlockingTypes.MONTHLY_ACTIVE_USER, ) diff --git a/synapse/api/constants.py b/synapse/api/constants.py
index 60e99e4663..312196675e 100644 --- a/synapse/api/constants.py +++ b/synapse/api/constants.py
@@ -131,3 +131,10 @@ class RelationTypes(object): ANNOTATION = "m.annotation" REPLACE = "m.replace" REFERENCE = "m.reference" + + +class LimitBlockingTypes(object): + """Reasons that a server may be blocked""" + + MONTHLY_ACTIVE_USER = "monthly_active_user" + HS_DISABLED = "hs_disabled"