diff options
author | Erik Johnston <erik@matrix.org> | 2015-01-06 10:55:43 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-01-06 10:55:43 +0000 |
commit | f0128f9600c59fbcb993bccbbbb32486009694d7 (patch) | |
tree | 65aaaabcd27fb2f7b679bfc271d186e7de1d82e8 /synapse/storage | |
parent | Merge branch 'develop' of github.com:matrix-org/synapse into erikj-perf (diff) | |
download | synapse-f0128f9600c59fbcb993bccbbbb32486009694d7.tar.xz |
Add RoomMemberStore.get_users_in_room, so that we can get the list of joined users without having to retrieve the full events
Diffstat (limited to 'synapse/storage')
-rw-r--r-- | synapse/storage/roommember.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/synapse/storage/roommember.py b/synapse/storage/roommember.py index 4e416c50b1..4921561fc3 100644 --- a/synapse/storage/roommember.py +++ b/synapse/storage/roommember.py @@ -123,6 +123,19 @@ class RoomMemberStore(SQLBaseStore): else: return None + def get_users_in_room(self, room_id): + def f(txn): + sql = ( + "SELECT m.user_id FROM room_memberships as m" + " INNER JOIN current_state_events as c" + " ON m.event_id = c.event_id" + " WHERE m.membership = ? AND m.room_id = ?" + ) + + txn.execute(sql, (Membership.JOIN, room_id)) + return [r[0] for r in txn.fetchall()] + return self.runInteraction("get_users_in_room", f) + def get_room_members(self, room_id, membership=None): """Retrieve the current room member list for a room. |