summary refs log tree commit diff
path: root/synapse/server_notices
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2020-05-22 21:47:07 +0100
committerGitHub <noreply@github.com>2020-05-22 21:47:07 +0100
commitf4269694ce51a04761e43fc5897d6f8fe0ea18cc (patch)
treed75ac87e2a6488399201e8680afed757e2131750 /synapse/server_notices
parentFix missing CORS headers on OPTION responses (#7560) (diff)
downloadsynapse-f4269694ce51a04761e43fc5897d6f8fe0ea18cc.tar.xz
Optimise some references to hs.config (#7546)
These are surprisingly expensive, and we only really need to do them at startup.
Diffstat (limited to 'synapse/server_notices')
-rw-r--r--synapse/server_notices/resource_limits_server_notices.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/synapse/server_notices/resource_limits_server_notices.py b/synapse/server_notices/resource_limits_server_notices.py
index d97166351e..73f2cedb5c 100644
--- a/synapse/server_notices/resource_limits_server_notices.py
+++ b/synapse/server_notices/resource_limits_server_notices.py
@@ -48,6 +48,12 @@ class ResourceLimitsServerNotices(object):
 
         self._notifier = hs.get_notifier()
 
+        self._enabled = (
+            hs.config.limit_usage_by_mau
+            and self._server_notices_manager.is_enabled()
+            and not hs.config.hs_disabled
+        )
+
     async def maybe_send_server_notice_to_user(self, user_id):
         """Check if we need to send a notice to this user, this will be true in
         two cases.
@@ -61,14 +67,7 @@ class ResourceLimitsServerNotices(object):
         Returns:
             Deferred
         """
-        if self._config.hs_disabled is True:
-            return
-
-        if self._config.limit_usage_by_mau is False:
-            return
-
-        if not self._server_notices_manager.is_enabled():
-            # Don't try and send server notices unless they've been enabled
+        if not self._enabled:
             return
 
         timestamp = await self._store.user_last_seen_monthly_active(user_id)