Strip out since/next_batch from Sticky Events which is moving to global pos

This commit is contained in:
Olivier 'reivilibre committed 2026-10-09 17:03:28 +00:00
1 parent 93368c7eb8
commit 1b1eb537c8
4 files changed
+22 -36

No files matched your search

+1 -4
View File
@@ -1246,10 +1246,7 @@ class SlidingSyncRestServlet(RestServlet):
)
}
return {
"rooms": rooms_out,
"next_batch": sticky_events.next_batch.serialise(),
}
return {"rooms": rooms_out}
def _serialise_thread_subscriptions(
+1 -2
View File
@@ -48,7 +48,7 @@ from synapse.types import (
ThreadSubscriptionsToken,
UserID,
)
from synapse.types.rest.client import SlidingSyncBody, SlidingSyncStickyEventsToken
from synapse.types.rest.client import SlidingSyncBody
from synapse.util.clock import Clock
from synapse.util.duration import Duration
@@ -437,7 +437,6 @@ class SlidingSyncResult:
"""
room_id_to_sticky_events: Mapping[str, list[FilteredEvent]]
next_batch: SlidingSyncStickyEventsToken
def __bool__(self) -> bool:
return bool(self.room_id_to_sticky_events)
-2
View File
@@ -522,12 +522,10 @@ class SlidingSyncBody(RequestBodyModel):
Attributes:
enabled
limit: maximum number of sticky events to return in the extension (default 100)
since: either a string with the Sticky Events since token or absent
"""
enabled: StrictBool = False
limit: NonNegativeStrictInt = 100
since: SlidingSyncStickyEventsToken | AbsentType = Absent
class ProfilesExtension(RequestBodyModel):
"""The Profile Updates extension (MSC4262)
@@ -90,7 +90,7 @@ class SlidingSyncStickyEventsExtensionTestCase(SlidingSyncBase):
self,
response_body: JsonDict,
expected_events_by_room: dict[str, list[str]] | None,
) -> str | None:
) -> None:
"""Assert the sliding sync response was successful and has the expected
sticky events.
@@ -109,10 +109,9 @@ class SlidingSyncStickyEventsExtensionTestCase(SlidingSyncBase):
# If there are no expected events, we shouldn't get anything in the response
if expected_events_by_room is None:
self.assertIsNone(sticky_events)
return None
return
self.assertIsNotNone(sticky_events)
self.assertIsInstance(sticky_events["next_batch"], str)
actual_rooms = sticky_events["rooms"]
# Check that we have the expected rooms
@@ -131,9 +130,6 @@ class SlidingSyncStickyEventsExtensionTestCase(SlidingSyncBase):
ttl = actual_event["unsigned"][EventUnsignedContentFields.STICKY_TTL]
self.assertIsInstance(ttl, int)
self.assertIn("next_batch", sticky_events)
return sticky_events["next_batch"]
def test_empty_sync(self) -> None:
"""Test that enabling sticky events extension works on initial and incremental sync,
even if there is no data.
@@ -192,23 +188,17 @@ class SlidingSyncStickyEventsExtensionTestCase(SlidingSyncBase):
}
response_body, _ = self.do_sync(sync_body, tok=user1_tok)
# Assert the response and then get the next_batch for the next sliding sync request
next_batch = self._assert_sticky_events_response(
response_body, {room_id: [sticky_event_id]}
)
assert next_batch is not None
# Assert the response
self._assert_sticky_events_response(response_body, {room_id: [sticky_event_id]})
# Do an incremental sync immediately again
sync_body = {
"lists": DUMMY_LISTS,
"extensions": {
"org.matrix.msc4354.sticky_events": {
"enabled": True,
"since": next_batch,
}
},
"extensions": {"org.matrix.msc4354.sticky_events": {"enabled": True}},
}
response_body, _ = self.do_sync(sync_body, tok=user1_tok)
response_body, _ = self.do_sync(
sync_body, since=response_body["pos"], tok=user1_tok
)
# Check we don't get that event again
self._assert_sticky_events_response(response_body, None)
@@ -223,7 +213,9 @@ class SlidingSyncStickyEventsExtensionTestCase(SlidingSyncBase):
)["event_id"]
# Now the incremental sync should give us that event
response_body, _ = self.do_sync(sync_body, tok=user1_tok)
response_body, _ = self.do_sync(
sync_body, since=response_body["pos"], tok=user1_tok
)
self._assert_sticky_events_response(
response_body, {room_id: [sticky_event_id2]}
)
@@ -570,7 +562,7 @@ class SlidingSyncStickyEventsExtensionTestCase(SlidingSyncBase):
# We expect to see the first 2 sticky events by stream order
# and they should be in that stream order
next_batch = self._assert_sticky_events_response(
self._assert_sticky_events_response(
response_body, {room_id: sticky_event_ids[0:2]}
)
@@ -580,13 +572,13 @@ class SlidingSyncStickyEventsExtensionTestCase(SlidingSyncBase):
"extensions": {
"org.matrix.msc4354.sticky_events": {
"enabled": True,
# This makes it incremental
"since": next_batch,
"limit": 3,
}
},
}
response_body, _ = self.do_sync(sync_body, tok=user1_tok)
response_body, _ = self.do_sync(
sync_body, since=response_body["pos"], tok=user1_tok
)
# Should get remaining events, in stream order again
self._assert_sticky_events_response(
@@ -634,7 +626,7 @@ class SlidingSyncStickyEventsExtensionTestCase(SlidingSyncBase):
response_body, _ = self.do_sync(sync_body, tok=user1_tok)
# We expect to see the first sticky event
next_batch = self._assert_sticky_events_response(
self._assert_sticky_events_response(
response_body, {room_id: sticky_event_ids[0:1]}
)
@@ -644,16 +636,16 @@ class SlidingSyncStickyEventsExtensionTestCase(SlidingSyncBase):
"extensions": {
"org.matrix.msc4354.sticky_events": {
"enabled": True,
# This makes it incremental
"since": next_batch,
"limit": 0,
}
},
}
response_body, _ = self.do_sync(sync_body, tok=user1_tok)
response_body, _ = self.do_sync(
sync_body, since=response_body["pos"], tok=user1_tok
)
# You could imagine a buggy system returns a `next_batch` here with no events,
# but Synapse just omits the response extension altogether.
next_batch = self._assert_sticky_events_response(response_body, None)
self._assert_sticky_events_response(response_body, None)
def test_deduplication_with_timeline(self) -> None:
"""