You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: proposals/4354-sticky-events.md
+40-40Lines changed: 40 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -89,8 +89,8 @@ To implement these properties, servers MUST:
89
89
Large volumes of events to send MUST NOT cause the sticky event to be dropped from the send queue on the server.
90
90
* When a new server joins the room, existing servers MUST attempt to **push** all of their own sticky events[^newjoiner].
91
91
* Ensure sticky events are **delivered** to clients via `/sync` in a new section of the sync response,
92
-
regardless of whether the sticky event falls within the timeline limit of the request. If there are too many sticky events,
93
-
the client is informed of this and can fetch the remaining sticky events via a new pagination endpoint.
92
+
regardless of whether the sticky event falls within the timeline limit of the request.
93
+
If there are too many sticky events to deliver at once, they will be delivered in subsequent `/sync` responses instead.
94
94
* Soft-failure **checks** MUST be re-evaluated when the membership state changes for a user with unexpired sticky events.[^softfail]
95
95
* History visibility **checks** MUST NOT be applied to sticky events. Any joined user is authorised to see sticky events
96
96
for the duration they remain sticky.[^hisvis]
@@ -118,7 +118,6 @@ The new `/sync` section looks like:
118
118
"state": { ... },
119
119
"timeline": { ... },
120
120
"sticky": {
121
-
"prev_batch":"s11_22_33_44_55_66_77_88",
122
121
"events": [
123
122
{
124
123
"sender":"@bob:example.com",
@@ -161,13 +160,24 @@ When sending sticky events down `/sync`, the `unsigned` section SHOULD have a `s
161
160
how many milliseconds until the sticky event expires. This provides a way to reduce clock skew between a local homeserver
162
161
and their connected clients. Clients SHOULD use this value to determine when the sticky event expires.
163
162
164
-
Over Simplified Sliding Sync, Sticky Events have their own extension `sticky_events`, which has the following response shape:
163
+
Over Simplified Sliding Sync, Sticky Events have their own extension `sticky_events`, which has the following request extension
164
+
shape:
165
165
166
166
```js
167
167
{
168
+
"enabled":true,
169
+
"limit":100, // optional (default 100, min 1): max number of events to return, server can override to a lower number
170
+
"since":"some_token"// optional: can be omitted on initial sync / when extension is only just enabled
171
+
}
172
+
```
173
+
174
+
and, when enabled, the following response extension shape:
175
+
176
+
```js
177
+
{
178
+
"next_batch":"some_token", // REQUIRED when there are changes
168
179
"rooms": {
169
180
"!726s6s6q:example.com": {
170
-
"prev_batch":"s11_22_33_44_55_66_77_88",
171
181
"events": [{
172
182
"sender":"@bob:example.com",
173
183
"type":"m.foo",
@@ -188,42 +198,35 @@ As with normal events, sticky events sent by ignored users MUST NOT be delivered
188
198
189
199
#### Pagination
190
200
191
-
If there are too many sticky events to return down `/sync`, the server may choose not to deliver all sticky events and
192
-
instead provide a `prev_batch` token which can be passed to a new endpoint to retrieve sticky events in that room. If all
193
-
sticky events were delivered, the `prev_batch` token is omitted from the Sync / Sliding Sync response object.
201
+
Because sticky events and to-device messages are alike in the way that they should be *reliably* delivered to
202
+
clients, without any gaps in the pagination, they follow the [MSC3885: Sliding Sync Extension: To-Device messages][MSC3885]
203
+
model for pagination in sliding sync.
194
204
195
-
This proposal recommends only sending a `prev_batch` token if there are more than 100 sticky events in a given room. This
196
-
minimises the chances that clients will need to paginate, improving responsiveness at the cost of higher initial bandwidth used.
205
+
In short: when there are too many sticky events to return in one response, the server returns a limited number
206
+
of the oldest sticky events that have not yet been delivered.
197
207
198
-
The API shape follows the one proposed in [MSC4308: Thread Subscriptions extension to Sliding Sync](https://github.com/matrix-org/matrix-spec-proposals/blob/rei/msc_ssext_threadsubs/proposals/4308-sliding-sync-ext-thread-subscriptions.md#companion-endpoint-for-backpaginating-thread-subscription-changes):
208
+
At every response, the server returns a `next_batch` token which the client MUST persist and send
209
+
as a `since` token in the next Sliding Sync request (in the extension), if the client wishes to advance
210
+
in the sticky events stream.
199
211
200
-
```
201
-
GET /_matrix/client/v1/rooms/{roomId}/sticky_events
202
-
```
203
-
URL query parameters:
204
-
- dir (string, required): always `b` (backward), to mirror other pagination endpoints. The forward direction is not yet specified to be implemented.
205
-
- from (string, optional): a token used to continue backpaginating
206
-
The token is either acquired from a previous `/sticky_events` response, or the `prev_batch` in a Sliding Sync / Sync response.
207
-
The token is opaque and has no client-discernible meaning.
208
-
If this token is not provided, then backpagination starts from the 'end'.
209
-
- to (string, optional): a token used to limit the backpagination
210
-
The token, originally acquired from pos in a Sliding Sync response, would be the same one used as the pos request parameter in the Sliding Sync request that returned the prev_batch.
211
-
- limit (int, optional; default 100): a maximum number of sticky events to fetch in one response.
212
-
Must be greater than zero. Servers may impose a smaller limit than requested.
213
-
214
-
Response body:
215
-
```js
216
-
{
217
-
"sticky_events": [ ... ], // list of sticky events
218
-
// If there are still more sticky events to fetch,
219
-
// a new `from` token the client can use to walk further
220
-
// backwards. (The `to` token, if used, should be reused.)
221
-
"end":"OPAQUE_TOKEN"
222
-
}
223
-
```
212
+
However, we don't require `next_batch` to be provided in the response when there are no changes, because that seems
213
+
like a mistake, which would lead to unnecessarily high quiescent bandwidth usage if many extensions follow this pattern.
214
+
[There is a comment thread open on MSC3885.](https://github.com/matrix-org/matrix-spec-proposals/pull/3885#discussion_r2623950713).
215
+
216
+
One concern is that [MSC3885] has not yet been updated to account for [MSC4186 'Simplified' Sliding Sync][MSC4186],
217
+
the 'modern-day' dialect of Sliding Sync, so it is unknown whether this pattern will remain in use.
218
+
Whatever happens, this MSC should likely follow the same evolution as that one.
Another concern is a potential problem that we are calling 'flickering'.
224
+
This is where due to oldest-first pagination, a client might briefly display stale data before
225
+
near-immediately updating it with later data, despite that later data already having been 'available'
226
+
on the server.
224
227
225
-
NB: This endpoint may also be used to retrieve sticky events in a room without calling `/sync` at all (by omitting both `from` and `to`),
226
-
which may be useful for bots.
228
+
With that said, given this is an edge case that requires a substantial number of sticky events to trigger,
229
+
we don't currently consider it worthwhile to add complexity to avoid.
227
230
228
231
### Rate limits
229
232
@@ -315,8 +318,6 @@ following protections in place:
315
318
* All sticky events are subject to normal PDU checks, meaning that the sender must be authorised to send events into the room.
316
319
* Servers sending lots of sticky events may be asked to try again later as a form of rate-limiting.
317
320
Due to data expiring, subsequent requests will gradually have less data.
318
-
* Sticky events are returned down `/sync` with a recommended limit of 100 per room to ensure clients never get a single enormous `/sync` response. They
319
-
will still get all unexpired sticky events via the pagination endpoint.
320
321
321
322
322
323
## Alternatives
@@ -378,7 +379,6 @@ In the common case, it provides protection against clock skew when clients have
378
379
- The sticky key in the `content` of the PDU is `msc4354_sticky_key`.
379
380
- To enable this in SSS, the extension name is `org.matrix.msc4354.sticky_events`.
380
381
- The `unsigned.sticky_duration_ttl_ms` field is `unsigned.msc4354_sticky_duration_ttl_ms`
381
-
- The endpoint `/_matrix/client/v1/rooms/{roomId}/sticky_events` is `/_matrix/client/unstable/org.matrix.msc4354/rooms/{roomId}/sticky_events`.
0 commit comments