Ignore leave events for bg updates

This commit is contained in:
Erik Johnston 2024-09-02 10:33:39 +01:00
parent 596b96411b
commit b03dc0a997

View file

@ -1927,10 +1927,11 @@ class EventsBackgroundUpdatesStore(StreamWorkerStore, StateDeltasStore, SQLBaseS
LEFT JOIN rooms AS r ON (c.room_id = r.room_id)
WHERE (c.room_id, c.user_id) > (?, ?)
AND (m.user_id IS NULL OR c.event_id != m.membership_event_id)
AND (c.membership != ? OR c.user_id != e.sender)
ORDER BY c.room_id ASC, c.user_id ASC
LIMIT ?
""",
(last_room_id, last_user_id, batch_size),
(last_room_id, last_user_id, Membership.LEAVE, batch_size),
)
elif last_event_stream_ordering is not None:
# It's important to sort by `event_stream_ordering` *ascending* (oldest to
@ -1961,10 +1962,11 @@ class EventsBackgroundUpdatesStore(StreamWorkerStore, StateDeltasStore, SQLBaseS
LEFT JOIN rooms AS r ON (c.room_id = r.room_id)
WHERE c.event_stream_ordering > ?
AND (m.user_id IS NULL OR c.event_id != m.membership_event_id)
AND (c.membership != ? OR c.user_id != e.sender)
ORDER BY c.event_stream_ordering ASC
LIMIT ?
""",
(last_event_stream_ordering, batch_size),
(last_event_stream_ordering, Membership.LEAVE, batch_size),
)
else:
raise Exception("last_event_stream_ordering should not be None")