summary refs log tree commit diff
path: root/synapse/storage/data_stores
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-12-04 10:16:44 +0000
committerErik Johnston <erik@matrix.org>2019-12-04 16:23:43 +0000
commitc2f525a5251f4cbaef0cf34d6c69b42356c1f8af (patch)
tree7bc4c79a2f3ce1bdd38a95ba2480a73ad0fb8f93 /synapse/storage/data_stores
parentMerge pull request #6454 from matrix-org/erikj/clean_base_Store (diff)
downloadsynapse-c2f525a5251f4cbaef0cf34d6c69b42356c1f8af.tar.xz
Don't call SQLBaseStore methods from outside stores
Diffstat (limited to 'synapse/storage/data_stores')
-rw-r--r--synapse/storage/data_stores/main/roommember.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/synapse/storage/data_stores/main/roommember.py b/synapse/storage/data_stores/main/roommember.py
index 2af24a20b7..b314d75941 100644
--- a/synapse/storage/data_stores/main/roommember.py
+++ b/synapse/storage/data_stores/main/roommember.py
@@ -15,6 +15,7 @@
 # limitations under the License.
 
 import logging
+from typing import Iterable, List
 
 from six import iteritems, itervalues
 
@@ -813,6 +814,22 @@ class RoomMemberWorkerStore(EventsWorkerStore):
 
         return set(room_ids)
 
+    def get_membership_from_event_ids(
+        self, member_event_ids: Iterable[str]
+    ) -> List[dict]:
+        """Get user_id and membership of a set of event IDs.
+        """
+
+        return self._simple_select_many_batch(
+            table="room_memberships",
+            column="event_id",
+            iterable=member_event_ids,
+            retcols=("user_id", "membership", "event_id"),
+            keyvalues={},
+            batch_size=500,
+            desc="get_membership_from_event_ids",
+        )
+
 
 class RoomMemberBackgroundUpdateStore(BackgroundUpdateStore):
     def __init__(self, db_conn, hs):