wip commit to suppress mau alerting for small instances

This commit is contained in:
Neil Johnson 2019-10-04 17:53:45 +01:00
parent ae0b78cb1f
commit 11ccbc6576
2 changed files with 20 additions and 0 deletions

View file

@ -169,6 +169,7 @@ class ServerConfig(Config):
) )
self.mau_trial_days = config.get("mau_trial_days", 0) 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 # How long to keep redacted events in the database in unredacted form
# before redacting them. # before redacting them.
@ -693,9 +694,16 @@ class ServerConfig(Config):
# sign up in a short space of time never to return after their initial # sign up in a short space of time never to return after their initial
# session. # 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 #limit_usage_by_mau: False
#max_mau_value: 50 #max_mau_value: 50
#mau_trial_days: 2 #mau_trial_days: 2
#mau_alerting_threshold: 10
# If enabled, the metrics for the number of monthly active users will # 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 # be populated, however no one will be limited. If limit_usage_by_mau

View file

@ -91,6 +91,18 @@ class ResourceLimitsServerNotices(object):
currently_blocked, ref_events = yield self._is_room_currently_blocked(room_id) currently_blocked, ref_events = yield self._is_room_currently_blocked(room_id)
try: 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 # 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 # this case are checking what would happen to other users if they
# were to arrive. # were to arrive.