Skip to content

Commit 65941f5

Browse files
committed
Remove unnecessary clamping
1 parent de59b63 commit 65941f5

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

synapse/storage/databases/main/thread_subscriptions.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,14 @@ def _should_skip_autosubscription_after_unsubscription(
133133
# For normal rooms, these two orderings should be positive, because
134134
# they don't refer to a specific event but rather the maximum at the
135135
# time of unsubscription.
136+
#
136137
# However, for rooms that have never been joined and that are being peeked at,
137138
# 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-
)
139+
# ordering might be negative, so we don't assert this case.
144140
assert unsubscribed_at.topological > 0
145141

146-
if unsubscribed_at.stream >= autosub.stream > 0:
142+
unsubscribed_at_backfilled = unsubscribed_at.stream < 0
143+
if unsubscribed_at_backfilled and unsubscribed_at.stream >= autosub.stream > 0:
147144
# non-backfilled events: the unsubscription is later according to
148145
# the stream
149146
return True

0 commit comments

Comments
 (0)