do mau checks based on monthly_active_users table

This commit is contained in:
Neil Johnson 2018-08-02 16:57:35 +01:00
parent 9180061b49
commit 74b1d46ad9
7 changed files with 97 additions and 61 deletions

View file

@ -773,3 +773,16 @@ class Auth(object):
raise AuthError(
403, "Guest access not allowed", errcode=Codes.GUEST_ACCESS_FORBIDDEN
)
@defer.inlineCallbacks
def check_auth_blocking(self, error):
"""Checks if the user should be rejected for some external reason,
such as monthly active user limiting or global disable flag
Args:
error (Error): The error that should be raised if user is to be
blocked
"""
if self.hs.config.limit_usage_by_mau is True:
current_mau = yield self.store.get_monthly_active_count()
if current_mau >= self.hs.config.max_mau_value:
raise error