summary refs log tree commit diff
path: root/synapse/api
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2020-03-16 15:27:03 +0000
committerAndrew Morgan <andrew@amorgan.xyz>2020-03-16 15:27:03 +0000
commit759e8dd7934b29174204654da5f82bb55bec7e7a (patch)
treef0d4678f7fd9e989c6249759cc2913d1dd1d474a /synapse/api
parentCleanup extra quotes from IDEs (#6236) (diff)
parentOption to suppress resource exceeded alerting (#6173) (diff)
downloadsynapse-759e8dd7934b29174204654da5f82bb55bec7e7a.tar.xz
Option to suppress resource exceeded alerting (#6173)
* commit '2794b7905':
  Option to suppress resource exceeded alerting (#6173)
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 b00278b5b0..7613e3de68 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,
@@ -731,7 +737,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)
@@ -764,5 +770,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 f8ac03fc14..50ddff2934 100644
--- a/synapse/api/constants.py
+++ b/synapse/api/constants.py
@@ -134,3 +134,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"