Skip to content
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

Enable JSON filters in /sync for guests #3651

Closed
davidisaaclee opened this issue Aug 6, 2023 · 2 comments
Closed

Enable JSON filters in /sync for guests #3651

davidisaaclee opened this issue Aug 6, 2023 · 2 comments

Comments

@davidisaaclee
Copy link
Contributor

davidisaaclee commented Aug 6, 2023

Filters passed to startClient are ignored when client.isGuest():

matrix-js-sdk/src/sync.ts

Lines 730 to 733 in 2ef7ae7

if (this.client.isGuest()) {
// no push rules for guests, no access to POST filter for guests.
return this.doSync({});
}

It's reasonable to ignore saved filter IDs here, because guests can't save filters. But I think guests can use literal JSON filters in /sync – when I run the following with a guest access token against a Synapse server, I get the sync response with the room's events:

curl -X GET 'https://myserver.com/_matrix/client/r0/sync?filter=%7B%22room%22%3A%7B%22rooms%22%3A%5B%22%21IFwaPwKWSVQuKFbDZQ%3Amyserver.com%22%5D%7D%7D' \
                    -H 'Authorization: Bearer <guest_token>'

I would like to use the built-in client syncing so that I can use existing code interacting with the client's store (e.g. client.getRoom()) when accessing a single world_readable room as a guest (the concrete feature is a "web public room," like view.matrix.org but in-browser).

I couldn't find anything in the spec that says JSON filters should not be usable by guests. Would this be a welcome change?

@davidisaaclee
Copy link
Contributor Author

I filed too soon – the response from the mentioned /sync call does not include events from the allowlisted room, which indicates to me that JSON filters are not supported for guests. (I checked this by running the same request using a non-guest access token which has access to the specified room, which gave me back a list of the events I expected.)

@davidisaaclee
Copy link
Contributor Author

For anyone coming here from a search (#998 hints that, at least as of 2019, there has been confusion around use of matrix-js-sdk with guest access), I ended up using client.peekInRoom + the existing client store accessors like client.getRoom(), which appears to be working well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant