mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-03 02:54:52 -04:00
create support user (#4141)
Allow for the creation of a support user. A support user can access the server, join rooms, interact with other users, but does not appear in the user directory nor does it contribute to monthly active user limits.
This commit is contained in:
parent
e93a0ebf50
commit
d2f7c4e6b1
20 changed files with 371 additions and 47 deletions
|
@ -55,9 +55,12 @@ class MonthlyActiveUsersStore(SQLBaseStore):
|
|||
txn,
|
||||
tp["medium"], tp["address"]
|
||||
)
|
||||
|
||||
if user_id:
|
||||
self.upsert_monthly_active_user_txn(txn, user_id)
|
||||
reserved_user_list.append(user_id)
|
||||
is_support = self.is_support_user_txn(txn, user_id)
|
||||
if not is_support:
|
||||
self.upsert_monthly_active_user_txn(txn, user_id)
|
||||
reserved_user_list.append(user_id)
|
||||
else:
|
||||
logger.warning(
|
||||
"mau limit reserved threepid %s not found in db" % tp
|
||||
|
@ -182,6 +185,18 @@ class MonthlyActiveUsersStore(SQLBaseStore):
|
|||
Args:
|
||||
user_id (str): user to add/update
|
||||
"""
|
||||
# Support user never to be included in MAU stats. Note I can't easily call this
|
||||
# from upsert_monthly_active_user_txn because then I need a _txn form of
|
||||
# is_support_user which is complicated because I want to cache the result.
|
||||
# Therefore I call it here and ignore the case where
|
||||
# upsert_monthly_active_user_txn is called directly from
|
||||
# _initialise_reserved_users reasoning that it would be very strange to
|
||||
# include a support user in this context.
|
||||
|
||||
is_support = yield self.is_support_user(user_id)
|
||||
if is_support:
|
||||
return
|
||||
|
||||
is_insert = yield self.runInteraction(
|
||||
"upsert_monthly_active_user", self.upsert_monthly_active_user_txn,
|
||||
user_id
|
||||
|
@ -200,6 +215,16 @@ class MonthlyActiveUsersStore(SQLBaseStore):
|
|||
in a database thread rather than the main thread, and we can't call
|
||||
txn.call_after because txn may not be a LoggingTransaction.
|
||||
|
||||
We consciously do not call is_support_txn from this method because it
|
||||
is not possible to cache the response. is_support_txn will be false in
|
||||
almost all cases, so it seems reasonable to call it only for
|
||||
upsert_monthly_active_user and to call is_support_txn manually
|
||||
for cases where upsert_monthly_active_user_txn is called directly,
|
||||
like _initialise_reserved_users
|
||||
|
||||
In short, don't call this method with support users. (Support users
|
||||
should not appear in the MAU stats).
|
||||
|
||||
Args:
|
||||
txn (cursor):
|
||||
user_id (str): user to add/update
|
||||
|
@ -208,6 +233,7 @@ class MonthlyActiveUsersStore(SQLBaseStore):
|
|||
bool: True if a new entry was created, False if an
|
||||
existing one was updated.
|
||||
"""
|
||||
|
||||
# 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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue