summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorNeil Johnson <neil@fragile.org.uk>2018-08-06 23:25:25 +0100
committerNeil Johnson <neil@fragile.org.uk>2018-08-06 23:25:25 +0100
commita74b25faaaf47b4696cb30207ef2eae6a3a5d8c7 (patch)
tree814cfd793ecfd6a0d4400d03b14c48e3c5432b9f /synapse
parentadd default mau_limits_reserved_threepids (diff)
downloadsynapse-a74b25faaaf47b4696cb30207ef2eae6a3a5d8c7.tar.xz
WIP building out mau reserved users
Diffstat (limited to 'synapse')
-rw-r--r--synapse/storage/monthly_active_users.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/synapse/storage/monthly_active_users.py b/synapse/storage/monthly_active_users.py
index abe1e6bb99..6a37d6fc22 100644
--- a/synapse/storage/monthly_active_users.py
+++ b/synapse/storage/monthly_active_users.py
@@ -19,16 +19,30 @@ from synapse.util.caches.descriptors import cached
 
 from ._base import SQLBaseStore
 
+
 # Number of msec of granularity to store the monthly_active_user timestamp
 # This means it is not necessary to update the table on every request
 LAST_SEEN_GRANULARITY = 60 * 60 * 1000
 
 
 class MonthlyActiveUsersStore(SQLBaseStore):
+    @defer.inlineCallbacks
     def __init__(self, dbconn, hs):
         super(MonthlyActiveUsersStore, self).__init__(None, hs)
         self._clock = hs.get_clock()
         self.hs = hs
+        threepids = self.hs.config.mau_limits_reserved_threepids
+        self.reserved_user_ids = set()
+        for tp in threepids:
+            user_id = yield hs.get_datastore().get_user_id_by_threepid(
+                tp["medium"], tp["address"]
+            )
+            if user_id:
+                self.reserved_user_ids.add(user_id)
+            else:
+                logger.warning(
+                    "mau limit reserved threepid %s not found in db" % tp
+                )
 
     def reap_monthly_active_users(self):
         """
@@ -78,7 +92,7 @@ class MonthlyActiveUsersStore(SQLBaseStore):
 
     @cached(num_args=0)
     def get_monthly_active_count(self):
-        """Generates current count of monthly active users.abs
+        """Generates current count of monthly active users
 
         Returns:
             Defered[int]: Number of current monthly active users