Skip to content

Commit

Permalink
Make event stream storage return all membership events about the user…
Browse files Browse the repository at this point in the history
…, regardless of if they were in the room or not.
  • Loading branch information
erikjohnston committed Aug 20, 2014
1 parent 7371e68 commit ebd3c41
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions synapse/storage/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,12 @@ def get_room_events_stream(self, user_id, from_key, to_key, room_id,
"WHERE m.user_id = ?"
)

invites_sql = (
# We also want to get any membership events about that user, e.g.
# invites or leave notifications.
membership_sql = (
"SELECT m.event_id FROM room_memberships as m "
"INNER JOIN current_state_events as c ON m.event_id = c.event_id "
"WHERE m.user_id = ? AND m.membership = ?"
"WHERE m.user_id = ? "
)

if limit:
Expand All @@ -178,13 +180,13 @@ def get_room_events_stream(self, user_id, from_key, to_key, room_id,
"ORDER BY stream_ordering ASC LIMIT %(limit)d "
) % {
"current": current_room_membership_sql,
"invites": invites_sql,
"invites": membership_sql,
"limit": limit
}

rows = yield self._execute_and_decode(
sql,
user_id, user_id, Membership.INVITE, from_id, to_id
user_id, user_id, from_id, to_id
)

ret = [self._parse_event_from_row(r) for r in rows]
Expand Down

0 comments on commit ebd3c41

Please sign in to comment.