mirror of
https://github.com/element-hq/synapse.git
synced 2024-12-20 19:10:45 +03:00
wip commit to suppress mau alerting for small instances
This commit is contained in:
parent
ae0b78cb1f
commit
11ccbc6576
2 changed files with 20 additions and 0 deletions
|
@ -169,6 +169,7 @@ class ServerConfig(Config):
|
|||
)
|
||||
|
||||
self.mau_trial_days = config.get("mau_trial_days", 0)
|
||||
self.mau_alerting_threshold = config.get('mau_alerting_threshold', 0)
|
||||
|
||||
# How long to keep redacted events in the database in unredacted form
|
||||
# before redacting them.
|
||||
|
@ -693,9 +694,16 @@ class ServerConfig(Config):
|
|||
# sign up in a short space of time never to return after their initial
|
||||
# session.
|
||||
#
|
||||
# 'mau_alerting_threshold' is a means of limiting client side alerting
|
||||
# should the mau limit be reached. This is useful for small instances
|
||||
# where the admin has 5 mau seats (say) for 5 specific people and no
|
||||
# interest increasing the mau limit further. Defaults to 0 which denotes
|
||||
# that the option is disabled.
|
||||
#
|
||||
#limit_usage_by_mau: False
|
||||
#max_mau_value: 50
|
||||
#mau_trial_days: 2
|
||||
#mau_alerting_threshold: 10
|
||||
|
||||
# If enabled, the metrics for the number of monthly active users will
|
||||
# be populated, however no one will be limited. If limit_usage_by_mau
|
||||
|
|
|
@ -91,6 +91,18 @@ class ResourceLimitsServerNotices(object):
|
|||
currently_blocked, ref_events = yield self._is_room_currently_blocked(room_id)
|
||||
|
||||
try:
|
||||
if (
|
||||
self._config.mau_alerting_threshold > 0
|
||||
and self._config.mau_alerting_threshold > self._config.max_mau_value
|
||||
):
|
||||
# Alerting disabled, reset room if necessary and return
|
||||
if currently_blocked:
|
||||
content = {"pinned": ref_events}
|
||||
yield self._server_notices_manager.send_notice(
|
||||
user_id, content, EventTypes.Pinned, ""
|
||||
)
|
||||
return
|
||||
|
||||
# Normally should always pass in user_id if you have it, but in
|
||||
# this case are checking what would happen to other users if they
|
||||
# were to arrive.
|
||||
|
|
Loading…
Reference in a new issue