-
Notifications
You must be signed in to change notification settings - Fork 379
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
MSC3567: Allow requesting events from the start/end of the room history #3567
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6125ffc
Initial cut of MSC to standardize from being optiona on /messages req…
clokep 074773b
Fix typo.
clokep af730c0
Clarifications of start/end.
clokep c63cd31
Add information about back-paginating excluded events.
clokep ca5afae
Merge remote-tracking branch 'origin/main' into clokep/messages-from
clokep File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# MSC3567: Allow requesting events from the start/end of the room history | ||
|
||
It can be useful to request the latest events in a room directly without calling | ||
`/_matrix/client/v3/sync` first to fetch the room state. Some use-cases include: | ||
|
||
* Requesting events using a different filter after receiving a `/sync` response. | ||
clokep marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* A client which does not need to fully sync an account, but wishes to inspect a | ||
specific room's history (perhaps for exporting or auditing). | ||
richvdh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
## Proposal | ||
|
||
The `from` field on the [`/_matrix/client/v3/rooms/{roomId}/messages`](https://spec.matrix.org/v1.1/client-server-api/#get_matrixclientv3roomsroomidmessages) | ||
becomes optional. If it is not provided, the homeserver shall return a list of | ||
messages from the first or last (per the value of the `dir` parameter) visible | ||
event in the room history for the requesting user. | ||
|
||
Note that Synapse already implements this, but it is not spec-compliant. It is | ||
known to be used by Element Android [^1] and Element Web, and there are other | ||
use-cases involving threads [^2], which shows real-world usage that this would | ||
be valuable. | ||
|
||
Ideally this would not be necessary and the `prev_batch` token received from | ||
calling `/sync` could be provided as the pagination token to `/messages`, but this | ||
will not work if you `/sync` with a filter that excludes a given class of event | ||
(such as threaded replies), and all the events taking place in a room are of that | ||
class. This will result in your `/sync` not returning an update for that room, | ||
which means that your most recent `prev_batch` token precedes all the excluded | ||
events. Trying to back-paginate from `prev_batch` using `/messages` will not | ||
result in seeing the excluded events. | ||
|
||
|
||
## Potential issues | ||
|
||
None. | ||
|
||
|
||
## Alternatives | ||
|
||
The alternative is today's status quo: a client must first make a request to | ||
`/_matrix/client/v3/sync` and then follow-up that request with queries to | ||
`/_matrix/client/v3/rooms/{roomId}/messages`. This is clunky if the client is | ||
going to throw away most of the information received from the `/sync` request. | ||
richvdh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
The behavior also seems undefined if a different `filter` parameter is provided | ||
for the call to `/sync` compared to the one used for `/messages`. | ||
|
||
|
||
## Security considerations | ||
|
||
None. | ||
|
||
|
||
## Unstable prefix | ||
|
||
Since this is modifying the endpoint to support not including a field, no unstable | ||
prefix is necessary. | ||
|
||
|
||
## Dependencies | ||
|
||
N/A | ||
|
||
[^1]: https://github.com/matrix-org/synapse/issues/5538 | ||
|
||
[^2]: In order to list all threads in a room without pulling the history locally | ||
it uses `/messages` to push the filtering onto the homeserver. See https://github.com/matrix-org/matrix-js-sdk/pull/2065 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is there a reason why synapse supports pagination from the start of the room history?