summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorNeil Johnson <neil@matrix.org>2018-09-12 17:14:04 +0100
committerGitHub <noreply@github.com>2018-09-12 17:14:04 +0100
commitf30a30359074647de6e000ac9eb70e6bc84d9df8 (patch)
tree3689904805e4d57a75184d197c97ef44ef9d7e60 /synapse/storage
parentshow heroes if a room has a 'deleted' name/canonical_alias (#3851) (diff)
parentimprove naming (diff)
downloadsynapse-f30a30359074647de6e000ac9eb70e6bc84d9df8.tar.xz
Merge pull request #3846 from matrix-org/neilj/expose-registered-users hhs-7
expose number of real reserved users
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/monthly_active_users.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/synapse/storage/monthly_active_users.py b/synapse/storage/monthly_active_users.py
index b890c152db..59580949f1 100644
--- a/synapse/storage/monthly_active_users.py
+++ b/synapse/storage/monthly_active_users.py
@@ -147,6 +147,23 @@ class MonthlyActiveUsersStore(SQLBaseStore):
         return self.runInteraction("count_users", _count_users)
 
     @defer.inlineCallbacks
+    def get_registered_reserved_users_count(self):
+        """Of the reserved threepids defined in config, how many are associated
+        with registered users?
+
+        Returns:
+            Defered[int]: Number of real reserved users
+        """
+        count = 0
+        for tp in self.hs.config.mau_limits_reserved_threepids:
+            user_id = yield self.hs.get_datastore().get_user_id_by_threepid(
+                tp["medium"], tp["address"]
+            )
+            if user_id:
+                count = count + 1
+        defer.returnValue(count)
+
+    @defer.inlineCallbacks
     def upsert_monthly_active_user(self, user_id):
         """
             Updates or inserts monthly active user member