-
Notifications
You must be signed in to change notification settings - Fork 412
MSC4308: Thread Subscriptions extension to Sliding Sync #4308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
5f22967
8ba12b4
878f8f5
6029082
9e03a06
ede25df
a5e3e78
058ce7f
5cf9c90
5b51570
cef3446
b3ac5ee
4d88858
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,169 @@ | ||||||
MSC4308: Thread Subscriptions extension to Sliding Sync | ||||||
=== | ||||||
|
||||||
## Background and Summary | ||||||
|
||||||
Threads were introduced in [version 1.4 of the Matrix Specification](https://spec.matrix.org/v1.13/changelog/v1.4/) as a way to isolate conversations in a room, making it easier for users to track specific conversations that they care about (and ignore those that they do not). | ||||||
|
||||||
Threads Subscriptions are proposed in [MSC4306](https://github.com/matrix-org/matrix-spec-proposals/blob/rei/msc_thread_subscriptions/proposals/4306-thread-subscriptions.md) as a way for users to efficiently indicate which threads they care about, for the purposes of receiving updates. | ||||||
|
||||||
Sliding Sync is proposed in [MSC4186](https://github.com/matrix-org/matrix-spec-proposals/blob/erikj/sss/proposals/4186-simplified-sliding-sync.md) as a paginated replacement to `/_matrix/client/v3/sync` with smaller response bodies and lower latency. | ||||||
The `/_matrix/client/v3/sync` endpoint is notorious in real-world applications of Matrix for producing large response bodies (to the amplified detriment of mobile clients) and the high latency caused by waiting for the server to calculate that full payload. | ||||||
|
||||||
This MSC proposes an 'extension' to Sliding Sync that allows clients to opt-in to receiving real-time updates to the user's thread subscriptions. | ||||||
|
||||||
To handle the case in which there have been many updates to the user's thread subscriptions and there are too many to return in | ||||||
Sliding Sync, a new companion endpoint is proposed to allow backpaginating thread subscriptions on the client's terms. | ||||||
|
||||||
## Proposal | ||||||
|
||||||
### Sliding Sync extension | ||||||
|
||||||
The Sliding Sync request format is extended to include the `thread_subscriptions` extension as follows: | ||||||
|
||||||
```jsonc | ||||||
{ | ||||||
// ... | ||||||
|
||||||
"extensions": { | ||||||
// ... | ||||||
|
||||||
// Used to opt-in to receiving changes to thread subscriptions. | ||||||
"thread_subscriptions": { | ||||||
// Maximum number of thread subscription changes to receive | ||||||
// in the response. | ||||||
// Defaults to 100. | ||||||
// Servers may impose a smaller limit than what is requested here. | ||||||
"limit": 100, | ||||||
} | ||||||
} | ||||||
} | ||||||
``` | ||||||
|
||||||
The response format is then extended to compensate: | ||||||
|
||||||
```jsonc | ||||||
{ | ||||||
// ... | ||||||
|
||||||
"extensions": { | ||||||
// ... | ||||||
|
||||||
// Returns a limited window of changes to thread subscriptions | ||||||
// Only the latest changes are returned in this window. | ||||||
"thread_subscriptions": { | ||||||
"changed": { | ||||||
|
||||||
"!roomId1:example.org": { | ||||||
// New subscription | ||||||
"$threadId1": { | ||||||
"automatic": true | ||||||
}, | ||||||
// New subscription | ||||||
// or subscription changed to manual | ||||||
"$threadId2": { | ||||||
"automatic": false | ||||||
}, | ||||||
// Represents a removed subscription | ||||||
"$threadId3": null | ||||||
}, | ||||||
"$roomId2:example.org": { | ||||||
// ... | ||||||
} | ||||||
// ... | ||||||
}, | ||||||
|
||||||
// A token that can be used to backpaginate other thread subscription | ||||||
// changes that occurred since the last sync, but that were not | ||||||
// included in this response. | ||||||
// | ||||||
// Only present when some thread subscriptions have been missed out | ||||||
// from the response because there are too many of them. | ||||||
"gap": "OPAQUE_TOKEN" | ||||||
|
||||||
} | ||||||
} | ||||||
} | ||||||
``` | ||||||
|
||||||
If two changes occur to the same subscription, only the latter change ever needs | ||||||
to be sent to the client. \ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these on purpose? (applies elsewhere)
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the most sane of the two ways of adding a line break in the more standard variants of Markdown. |
||||||
Servers do not need to store intermediate subscription states. | ||||||
|
||||||
|
||||||
### Companion endpoint for backpaginating thread subscription changes | ||||||
|
||||||
``` | ||||||
GET /_matrix/v1/thread_subscriptions | ||||||
|
||||||
``` | ||||||
|
||||||
URL parameters: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per my other comment,
This would also require a We should also clarify the token bounds. Synapse reference for other places: |
||||||
|
||||||
- `pos` (string, optional): a token used to continue backpaginating \ | ||||||
The token is either acquired from a previous `/thread_subscriptions` response, | ||||||
or a Sliding Sync response. \ | ||||||
The token is opaque and has no client-discernible meaning. \ | ||||||
If this token is not provided, then backpagination starts from the 'end'. | ||||||
|
||||||
- `limit` (int, optional; default `100`): a maximum number of thread subscriptions to fetch | ||||||
in one response. \ | ||||||
Must be greater than zero. Servers may impose a smaller limit than requested. | ||||||
|
||||||
Response body: | ||||||
|
||||||
``` | ||||||
reivilibre marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
{ | ||||||
// Required | ||||||
"chunk": { | ||||||
"!roomId1:example.org": { | ||||||
// New subscription | ||||||
"$threadId1": { | ||||||
"automatic": true | ||||||
}, | ||||||
// New subscription | ||||||
// or subscription changed to manual | ||||||
"$threadId2": { | ||||||
"automatic": false | ||||||
}, | ||||||
// Represents a removed subscription | ||||||
"$threadId3": null | ||||||
}, | ||||||
"$roomId2:example.org": { | ||||||
// ... | ||||||
} | ||||||
}, | ||||||
// If there are still more thread subscriptions to fetch, | ||||||
// a new `pos` token the client can use to walk further | ||||||
// backwards. | ||||||
"pos": "OPAQUE_TOKEN" | ||||||
} | ||||||
``` | ||||||
|
||||||
If two changes occur to the same subscription, only the latter change ever needs | ||||||
to be sent to the client. \ | ||||||
Servers do not need to store intermediate subscription states. | ||||||
|
||||||
|
||||||
## Potential issues | ||||||
|
||||||
|
||||||
## Alternatives | ||||||
|
||||||
|
||||||
## Limitations | ||||||
|
||||||
|
||||||
## Security considerations | ||||||
|
||||||
- No particular security issues anticipated. | ||||||
|
||||||
## Unstable prefix | ||||||
|
||||||
Whilst this proposal is unstable, a few unstable prefixes must be observed by experimental implementations: | ||||||
|
||||||
- the Sliding Sync extension is called `io.element.msc4308.thread_subscriptions` instead of `thread_subscriptions` | ||||||
- the companion endpoint is called `/_matrix/client/unstable/io.element.msc4308/thread_subscriptions` instead of `/_matrix/v1/thread_subscriptions` | ||||||
|
||||||
|
||||||
## Dependencies | ||||||
|
||||||
- [MSC4186 Sliding Sync](https://github.com/matrix-org/matrix-spec-proposals/blob/erikj/sss/proposals/4186-simplified-sliding-sync.md) | ||||||
- [MSC4306 Threads Subscriptions](https://github.com/matrix-org/matrix-spec-proposals/blob/rei/msc_thread_subscriptions/proposals/4306-thread-subscriptions.md) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enabled
: boolean here too, for consistency with other extensions (and because the synapse impl requires it, and I was confused as to why my request wasn't taken into account xD)limit
is required, but I wonder if it should? I didn't put it first, assuming the server would give me a nice default value.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the enabled flag, sorry for forgetting it!
The
limit
is now opened as a bug in Synapse.