summary refs log tree commit diff
path: root/synapse/storage/roommember.py
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2014-08-27 15:31:04 +0100
committerMark Haines <mark.haines@matrix.org>2014-08-27 16:51:54 +0100
commitb30358f439aeec4e249c0d21d761cf6742e65578 (patch)
treedc22532c93f3af8005d67942fb32c3f0710c808e /synapse/storage/roommember.py
parentStart updating state handling to use snapshots (diff)
downloadsynapse-b30358f439aeec4e249c0d21d761cf6742e65578.tar.xz
add _get_room_member, fix datastore methods
Diffstat (limited to '')
-rw-r--r--synapse/storage/roommember.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/synapse/storage/roommember.py b/synapse/storage/roommember.py
index 5038aeea03..2746126e85 100644
--- a/synapse/storage/roommember.py
+++ b/synapse/storage/roommember.py
@@ -50,13 +50,13 @@ class RoomMemberStore(SQLBaseStore):
                 "INSERT OR IGNORE INTO room_hosts (room_id, host) "
                 "VALUES (?, ?)"
             )
-            txn.execute(sql, event.room_id, domain)
+            txn.execute(sql, (event.room_id, domain))
         else:
             sql = (
                 "DELETE FROM room_hosts WHERE room_id = ? AND host = ?"
             )
 
-            txn.execute(sql, event.room_id, domain)
+            txn.execute(sql, (event.room_id, domain))
 
     @defer.inlineCallbacks
     def get_room_member(self, user_id, room_id):
@@ -75,6 +75,24 @@ class RoomMemberStore(SQLBaseStore):
 
         defer.returnValue(rows[0] if rows else None)
 
+    def _get_room_member(self, txn, user_id, room_id):
+        sql = (
+            "SELECT e.* FROM events as e"
+            " INNER JOIN room_memberships as m"
+            " ON e.event_id = m.event_id"
+            " INNER JOIN current_state_events as c"
+            " ON m.event_id = c.event_id"
+            " WHERE m.user_id = ? and e.room_id = ?"
+            " LIMIT 1"
+        )
+        txn.execute(sql, (user_id, room_id))
+        rows = self.cursor_to_dict(txn)
+        if rows:
+            return self._parse_event_from_row(rows[0])
+        else:
+            return None
+
+
     def get_room_members(self, room_id, membership=None):
         """Retrieve the current room member list for a room.