diff options
author | Neil Johnson <neil@matrix.org> | 2018-08-17 13:33:54 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-17 13:33:54 +0000 |
commit | 4c22b4047b53e36303c3513e21b3ba9b12ca14ce (patch) | |
tree | f0439ed7a668a2b0d627b78aaab25b03a2fb6514 /synapse/api/auth.py | |
parent | Merge pull request #3708 from matrix-org/neilj/resource_Limit_block_event_cre... (diff) | |
parent | Merge branch 'neilj/limit_exceeded_error' of github.com:matrix-org/synapse in... (diff) | |
download | synapse-4c22b4047b53e36303c3513e21b3ba9b12ca14ce.tar.xz |
Merge pull request #3707 from matrix-org/neilj/limit_exceeded_error
add new error type ResourceLimit
Diffstat (limited to 'synapse/api/auth.py')
-rw-r--r-- | synapse/api/auth.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/synapse/api/auth.py b/synapse/api/auth.py index ab1e3a4e35..022211e34e 100644 --- a/synapse/api/auth.py +++ b/synapse/api/auth.py @@ -25,7 +25,7 @@ from twisted.internet import defer import synapse.types from synapse import event_auth from synapse.api.constants import EventTypes, JoinRules, Membership -from synapse.api.errors import AuthError, Codes +from synapse.api.errors import AuthError, Codes, ResourceLimitError from synapse.types import UserID from synapse.util.caches import CACHE_SIZE_FACTOR, register_cache from synapse.util.caches.lrucache import LruCache @@ -784,10 +784,11 @@ class Auth(object): MAU cohort """ if self.hs.config.hs_disabled: - raise AuthError( + raise ResourceLimitError( 403, self.hs.config.hs_disabled_message, errcode=Codes.RESOURCE_LIMIT_EXCEED, admin_uri=self.hs.config.admin_uri, + limit_type=self.hs.config.hs_disabled_limit_type ) if self.hs.config.limit_usage_by_mau is True: # If the user is already part of the MAU cohort @@ -798,8 +799,10 @@ class Auth(object): # Else if there is no room in the MAU bucket, bail current_mau = yield self.store.get_monthly_active_count() if current_mau >= self.hs.config.max_mau_value: - raise AuthError( + raise ResourceLimitError( 403, "Monthly Active User Limit Exceeded", + admin_uri=self.hs.config.admin_uri, - errcode=Codes.RESOURCE_LIMIT_EXCEED + errcode=Codes.RESOURCE_LIMIT_EXCEED, + limit_type="monthly_active_user" ) |