diff options
author | David Baker <dave@matrix.org> | 2015-03-04 14:56:41 +0000 |
---|---|---|
committer | David Baker <dave@matrix.org> | 2015-03-04 14:56:41 +0000 |
commit | 92b3dc3219ccabc6997c66197a3b879dc49f5597 (patch) | |
tree | 083acae90fadadf500918d58754a628feff86351 /synapse/storage/roommember.py | |
parent | Use if not results rather than len, as per feedback. (diff) | |
parent | Fix upgrade instructions (diff) | |
download | synapse-92b3dc3219ccabc6997c66197a3b879dc49f5597.tar.xz |
Merge branch 'develop' into pushrules2
Diffstat (limited to 'synapse/storage/roommember.py')
-rw-r--r-- | synapse/storage/roommember.py | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/synapse/storage/roommember.py b/synapse/storage/roommember.py index 58aa376c20..65ffb4627f 100644 --- a/synapse/storage/roommember.py +++ b/synapse/storage/roommember.py @@ -180,6 +180,14 @@ class RoomMemberStore(SQLBaseStore): if not membership_list: return defer.succeed(None) + return self.runInteraction( + "get_rooms_for_user_where_membership_is", + self._get_rooms_for_user_where_membership_is_txn, + user_id, membership_list + ) + + def _get_rooms_for_user_where_membership_is_txn(self, txn, user_id, + membership_list): where_clause = "user_id = ? AND (%s)" % ( " OR ".join(["membership = ?" for _ in membership_list]), ) @@ -187,24 +195,18 @@ class RoomMemberStore(SQLBaseStore): args = [user_id] args.extend(membership_list) - def f(txn): - sql = ( - "SELECT m.room_id, m.sender, m.membership" - " FROM room_memberships as m" - " INNER JOIN current_state_events as c" - " ON m.event_id = c.event_id" - " WHERE %s" - ) % (where_clause,) - - txn.execute(sql, args) - return [ - RoomsForUser(**r) for r in self.cursor_to_dict(txn) - ] + sql = ( + "SELECT m.room_id, m.sender, m.membership" + " FROM room_memberships as m" + " INNER JOIN current_state_events as c" + " ON m.event_id = c.event_id" + " WHERE %s" + ) % (where_clause,) - return self.runInteraction( - "get_rooms_for_user_where_membership_is", - f - ) + txn.execute(sql, args) + return [ + RoomsForUser(**r) for r in self.cursor_to_dict(txn) + ] def get_joined_hosts_for_room(self, room_id): return self._simple_select_onecol( |