WIP creating and filtering support user
This commit is contained in:
@@ -555,6 +555,21 @@ def run(hs):
|
||||
clock.looping_call(generate_monthly_active_users, 5 * 60 * 1000)
|
||||
# End of monthly active user settings
|
||||
|
||||
if hs.config.autocreate_support_user:
|
||||
localpart = hs.config.autocreate_support_user['localpart']
|
||||
password = hs.config.autocreate_support_user['password']
|
||||
user_id = UserID(localpart, hs.hostname).to_string()
|
||||
# check not already created
|
||||
support_user = yield hs.get_datastore().get_users_by_id_case_insensitive(user_id)
|
||||
# if not create
|
||||
if not support_user:
|
||||
registration_handler = hs.get_handlers().registration_handler
|
||||
(user_id, token) = yield registration_handler.register(
|
||||
localpart=localpart,
|
||||
password=password,
|
||||
)
|
||||
|
||||
|
||||
if hs.config.report_stats:
|
||||
logger.info("Scheduling stats reporting for 3 hour intervals")
|
||||
clock.looping_call(start_phone_stats_home, 3 * 60 * 60 * 1000)
|
||||
|
||||
@@ -86,6 +86,8 @@ class ServerConfig(Config):
|
||||
"mau_trial_days", 0,
|
||||
)
|
||||
|
||||
self.autocreate_support_user = config.get('autocreate_support_user', None)
|
||||
|
||||
# Options to disable HS
|
||||
self.hs_disabled = config.get("hs_disabled", False)
|
||||
self.hs_disabled_message = config.get("hs_disabled_message", "")
|
||||
|
||||
@@ -33,6 +33,8 @@ class MonthlyActiveUsersStore(SQLBaseStore):
|
||||
self._clock = hs.get_clock()
|
||||
self.hs = hs
|
||||
self.reserved_users = ()
|
||||
localpart = self.hs.config.autocreate_support_user['localpart']
|
||||
self.support_user = UserId(localpart, hs.hostName).to_sting()
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def initialise_reserved_users(self, threepids):
|
||||
@@ -172,6 +174,9 @@ class MonthlyActiveUsersStore(SQLBaseStore):
|
||||
Deferred[bool]: True if a new entry was created, False if an
|
||||
existing one was updated.
|
||||
"""
|
||||
# Support user never to be included in MAU stats
|
||||
if user_id is self.support_user:
|
||||
return False
|
||||
# Am consciously deciding to lock the table on the basis that is ought
|
||||
# never be a big table and alternative approaches (batching multiple
|
||||
# upserts into a single txn) introduced a lot of extra complexity.
|
||||
|
||||
@@ -86,6 +86,9 @@ class UserDirectoryStore(SQLBaseStore):
|
||||
users_with_profile (dict): Users to add to directory in the form of
|
||||
mapping of user_id -> ProfileInfo
|
||||
"""
|
||||
# TODO Filter out support user
|
||||
|
||||
|
||||
if isinstance(self.database_engine, PostgresEngine):
|
||||
# We weight the loclpart most highly, then display name and finally
|
||||
# server name
|
||||
|
||||
Reference in New Issue
Block a user