Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Implement filtering for /roomId/messages #1809

Closed

Conversation

hulthe
Copy link

@hulthe hulthe commented Mar 26, 2021

Make GET /_matrix/client/r0/rooms/{roomId}/messages accept a filter parameter in
accordance with the spec (hopefully).

Related issue: #587

This is my first PR to a matrix-project, so there are a couple of thing I'm unsure about:

  • Database.GetEventsInTopologicalRange doesn't support filters, so if the client specifies a
    topological from-token filtering wont work. Not sure if this is intended.

  • limit can be set both as a query parameter, and as a part of RoomEventFilter.
    The spec doesn't seem to specify which takes precedence if both are specified.
    For now I've assumed that the query parameter takes precedence.

  • Curiously, the default limit value in gomatrixserverlib.RoomEventFilter is 20. I'm not sure
    if this is something I should adhere to, or event if it conforms to the spec, since the default for
    the query parameter is 10.

  • Unlike /sync, the spec doesn't seem to allow for the filter payload to be a filter_id
    instead of a JSON RoomEventFilter. Is this intended, or a spec oversight?

SyTest

Sadly, no new tests are passing (there doesn't seem to be many tests which handle filtering /messages),
although a couple of tests seem to be closer to passing than before:

  • Ephemeral messages received from clients are correctly expired
  • Ephemeral messages received from servers are correctly expired

These now fail for other reasons than filtering not working :)

Pull Request Checklist

  • I have added any new tests that need to pass to sytest-whitelist as specified in docs/sytest.md
  • Pull request includes a sign off

Signed-off-by: Joakim Hulthe <[email protected]>

@hulthe
Copy link
Author

hulthe commented Mar 26, 2021

Not sure why SyTest is failing in the CI. It seems to work on my machine 😕
The test in question (458) doesn't seem to have anything to do with the /messages endpoint

@kegsay kegsay self-requested a review June 7, 2021 09:59
Copy link
Member

@kegsay kegsay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to implement the topological filtering bit.

limit can be set both as a query parameter, and as a part of RoomEventFilter.
The spec doesn't seem to specify which takes precedence if both are specified.
For now I've assumed that the query parameter takes precedence.

Your assumption is the same as mine: limit takses precedence.

I would go for a 20 limit, not 10.

Unlike /sync, the spec doesn't seem to allow for the filter payload to be a filter_id
instead of a JSON RoomEventFilter. Is this intended, or a spec oversight?

Almost certainly a spec oversight. I didn't even know ?filter= was A Thing on /messages!

)
} else {
streamEvents, err = r.db.GetEventsInTopologicalRange(
r.ctx, r.from, r.to, r.roomID, r.limit, r.backwardOrdering,
r.ctx, r.from, r.to, r.roomID, r.filter.Limit, r.backwardOrdering,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need the filter object passed through to GetEventsInTopologicalRange and for it to be implemented there unfortunately!

@kegsay kegsay self-assigned this Jul 12, 2021
@kegsay kegsay added the stale This issue or PR is at risk of being closed without further feedback label Jul 12, 2021
@kegsay kegsay removed their assignment Jul 12, 2021
@kegsay
Copy link
Member

kegsay commented Jul 19, 2021

Stale. Please re-open when this has been brough up-to-date and the outstanding issues resolved. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
stale This issue or PR is at risk of being closed without further feedback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants