diff options
author | Neil Johnson <neil@matrix.org> | 2018-08-01 10:21:56 +0100 |
---|---|---|
committer | Neil Johnson <neil@matrix.org> | 2018-08-01 10:21:56 +0100 |
commit | 7931393495c76eef0af9b91c7904c88943197054 (patch) | |
tree | 2cde24c4b2f49ec0f21bd78500769ecc39de86ba /synapse/handlers | |
parent | only need to loop if mau limiting is enabled (diff) | |
download | synapse-7931393495c76eef0af9b91c7904c88943197054.tar.xz |
make count_monthly_users async synapse/handlers/auth.py
Diffstat (limited to 'synapse/handlers')
-rw-r--r-- | synapse/handlers/register.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/synapse/handlers/register.py b/synapse/handlers/register.py index f46b8355c0..cc935a5e84 100644 --- a/synapse/handlers/register.py +++ b/synapse/handlers/register.py @@ -144,7 +144,7 @@ class RegistrationHandler(BaseHandler): Raises: RegistrationError if there was a problem registering. """ - self._check_mau_limits() + yield self._check_mau_limits() password_hash = None if password: password_hash = yield self.auth_handler().hash(password) @@ -289,7 +289,7 @@ class RegistrationHandler(BaseHandler): 400, "User ID can only contain characters a-z, 0-9, or '=_-./'", ) - self._check_mau_limits() + yield self._check_mau_limits() user = UserID(localpart, self.hs.hostname) user_id = user.to_string() @@ -439,7 +439,7 @@ class RegistrationHandler(BaseHandler): """ if localpart is None: raise SynapseError(400, "Request must include user id") - self._check_mau_limits() + yield self._check_mau_limits() need_register = True try: @@ -534,13 +534,14 @@ class RegistrationHandler(BaseHandler): action="join", ) + @defer.inlineCallbacks def _check_mau_limits(self): """ Do not accept registrations if monthly active user limits exceeded and limiting is enabled """ if self.hs.config.limit_usage_by_mau is True: - current_mau = self.store.count_monthly_users() + current_mau = yield self.store.count_monthly_users() if current_mau >= self.hs.config.max_mau_value: raise RegistrationError( 403, "MAU Limit Exceeded", Codes.MAU_LIMIT_EXCEEDED |