'Given two user_ids find out the list of rooms they share.'

@defer.inlineCallbacks
def get_rooms_in_common_for_users(self, user_id, other_user_id):

    sql = "\n                                                SELECT    room_id    FROM    (\n                                                                SELECT    c.room_id    FROM    current_state_events    AS    c\n                                                                INNER    JOIN    room_memberships    USING    (event_id)\n                                                                WHERE    type    =    'm.room.member'\n                                                                                AND    membership    =    'join'\n                                                                                AND    state_key    =    ?\n                                                )    AS    f1    INNER    JOIN    (\n                                                                SELECT    c.room_id    FROM    current_state_events    AS    c\n                                                                INNER    JOIN    room_memberships    USING    (event_id)\n                                                                WHERE    type    =    'm.room.member'\n                                                                                AND    membership    =    'join'\n                                                                                AND    state_key    =    ?\n                                                )    f2    USING    (room_id)\n                                "
    rows = (yield self._execute('get_rooms_in_common_for_users', None, sql, user_id, other_user_id))
    defer.returnValue([room_id for (room_id,) in rows])
