-
Notifications
You must be signed in to change notification settings - Fork 399
MSC3874: Filtering threads from the /messages endpoint #3874
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
Open
justjanne
wants to merge
14
commits into
main
Choose a base branch
from
justjanne/messages-endpoint-threads-filter
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5afe6c3
MSC3874: Filtering threads from the /messages endpoint
justjanne 04ece96
Avoid accidental double spaces
justjanne 0061a08
Rephrase and clarify motivation
justjanne 5ef2e9e
Correct specified endpoint
justjanne 6fa06d8
Clarify and describe limitations
justjanne 86c88b4
Improve formatting
justjanne ceff9c9
Mark already merged PRs
justjanne df54176
Use production URL again
justjanne 6fff095
Correct issue where rel_types and related_by_rel_types got mixed up
justjanne 9476b7f
Add mobile reasoning to motivation
justjanne e28ba77
Clarify example
justjanne b14510f
Correct proposal wording
justjanne 747daf1
Address comments on proposal
justjanne 8d607ca
Apply suggestions from code review
justjanne 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 hidden or 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,94 @@ | ||
# MSC3874 Loading Messages excluding Threads | ||
|
||
## Motivation | ||
|
||
In Element's beta implementation of threads, it's become a noticeable issue where a room may have activity in a | ||
long-running thread while the main timeline is inactive. If a user starts their client and tries to paginate through the | ||
main timeline, loading will feel sluggish, as lots of events have to be loaded that won’t be displayed. | ||
|
||
This proposal would allow reducing the number of requests and amount of data transmitted. Especially for mobile usage | ||
this would allow clients significant usability improvements with threads. | ||
|
||
## Proposal | ||
|
||
### Allow filtering the `/messages` API by event relation type | ||
|
||
This proposal recommends extending the existing [Event filters] are extended with new filters, named `not_rel_types` and | ||
`rel_types`. If the `rel_types` filter is specified, messages which match any of the given relation types will be | ||
returned. If the `not_rel_types` filter is specified, only messages which match none of the given relation types will be | ||
returned, this includes events without a relation. | ||
|
||
If a relation type is present in both of these fields, `not_rel_types` takes precedence and messages with this type will | ||
not be returned. | ||
|
||
``` | ||
GET /_matrix/client/v3/rooms/!room_id:domain/messages?filter=... | ||
``` | ||
|
||
The filter string includes the new fields, above. In this example, the URL encoded JSON is presented unencoded and | ||
formatted for legibility: | ||
|
||
```jsonc | ||
{ | ||
"types": ["m.room.message"], | ||
"not_rel_types": ["m.thread"], | ||
"rel_types": ["m.edit"] | ||
} | ||
``` | ||
|
||
The newly added filtering parameters return events based on information in the `m.relates_to` field. Consider the following events in a room: | ||
|
||
* `A`: a `m.room.message` event sent by `alice` | ||
* `B`: a `m.room.message` event sent by `bob` | ||
* `C`: a `m.room.message` event sent by `charlie` which relates to `A` with type `m.thread` | ||
|
||
Using a filter of `"not_rel_types": ["m.thread"]` would return only events `A` and `B` as they do not have a relation of | ||
`m.thread` in them. | ||
|
||
## Potential issues | ||
|
||
This proposal moves the loading and processing of these hidden events onto the server. Depending on the server’s | ||
architecture, this may have a non-negligible performance impact. | ||
|
||
## Limitations | ||
|
||
While the client can effectively filter out noisy threads, it's not as easy to filter out events adjacent to threads | ||
such as reactions. A more performant implementation is best left for a future MSC. | ||
|
||
## Unstable prefix and versioning | ||
|
||
Relation filters might have sporadic support across servers, to simplify feature detections for clients, a homeserver | ||
must advertise unstable support for these filters as part of the `/versions` API: | ||
|
||
```jsonc | ||
{ | ||
"unstable_features": { | ||
"org.matrix.msc3874": true, | ||
// ... | ||
} | ||
} | ||
``` | ||
|
||
Unstable implementations should prefix the filter attributes with `org.matrix.msc3874`, e.g., | ||
|
||
```http request | ||
GET /_matrix/client/v3/rooms/!room_id:domain/messages?filter=... | ||
``` | ||
In this example, the URL encoded JSON is presented unencoded and formatted for legibility: | ||
```jsonc | ||
{ | ||
"types": ["m.room.message"], | ||
"org.matrix.msc3874.not_rel_types": ["m.thread"] | ||
} | ||
``` | ||
|
||
## Dependencies | ||
|
||
- [MSC2674](https://github.com/matrix-org/matrix-doc/pull/2674) ✓ | ||
- [MSC2675](https://github.com/matrix-org/matrix-doc/pull/2675) ✓ | ||
- [MSC3567](https://github.com/matrix-org/matrix-doc/pull/3567) ✓ | ||
- [MSC3676](https://github.com/matrix-org/matrix-doc/pull/3676) ✓ | ||
- [MSC3440](https://github.com/matrix-org/matrix-doc/pull/3440) ✓ | ||
|
||
<!-- inline links --> | ||
[Event filters]: https://spec.matrix.org/v1.2/client-server-api/#filtering |
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.
Uh oh!
There was an error while loading. Please reload this page.