File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
synapse/storage/databases/main Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -130,9 +130,17 @@ def _should_skip_autosubscription_after_unsubscription(
130130 Returns:
131131 True if the automatic subscription should be skipped
132132 """
133- # these two orderings should be positive, because they don't refer to a specific event
134- # but rather the maximum at the time of unsubscription
135- assert unsubscribed_at .stream > 0
133+ # For normal rooms, these two orderings should be positive, because
134+ # they don't refer to a specific event but rather the maximum at the
135+ # time of unsubscription.
136+ # However, for rooms that have never been joined and that are being peeked at,
137+ # we might not have a single non-backfilled event and therefore the stream
138+ # ordering might be negative.
139+ # In this case, we clamp it at zero and ensure we fall back to
140+ # using topological ordering.
141+ unsubscribed_at = attr .evolve (
142+ unsubscribed_at , stream = max (0 , unsubscribed_at .stream )
143+ )
136144 assert unsubscribed_at .topological > 0
137145
138146 if unsubscribed_at .stream >= autosub .stream > 0 :
You can’t perform that action at this time.
0 commit comments