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

MSC3715: Add a pagination direction parameter to /relations #3715

Merged
merged 13 commits into from
Sep 20, 2022
54 changes: 54 additions & 0 deletions proposals/3715-relations-parity-messages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# MSC3715: `/relations` parity with `/messages`
turt2live marked this conversation as resolved.
Show resolved Hide resolved
clokep marked this conversation as resolved.
Show resolved Hide resolved

[MSC2675](https://github.com/matrix-org/matrix-doc/pull/2675) introduced the
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm unsure it is worth including in this MSC (I don't think it is), but older versions of MSC2675 did include a dir parameter that was then dropped. matrix-org/synapse#11926 has some of the archaeology, but I'm not sure it is particularly interesting besides "we're not sure this is useful". It turns out that it was a surprise that these parameters were not supported and that it is useful if they are.

I can include more context here in the MSC if necessary, but I think letting this MSC stand on its own is probably better.

`/relations` API as an endpoint to paginate over the relations of an event. It
is described as behaving like the `/messages` API, but is missing parameters
to fully achieve that.


## Proposal
clokep marked this conversation as resolved.
Show resolved Hide resolved
clokep marked this conversation as resolved.
Show resolved Hide resolved

It is proposed to add the `dir`to the `/relations` API for parity with `/messages`,
clokep marked this conversation as resolved.
Show resolved Hide resolved
it will [have the same as definition as for `/messages`](https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3roomsroomidmessages),
which is copied below:

> The direction to return events from. If this is set to `f`, events will
> be returned in chronological order starting at `from`. If it is set to `b`,
> events will be returned in *reverse* chronological order, again starting at `from`.
>
> One of: `[b f]`.

Including the `dir` parameter will make it easier to request missing relation
information without needed to paginate through known information -- this is
particularly needed for mobile or low-bandwidth devices where it is desired to
keep the round-trips to the server to a minimum.

It is additionally useful to unify similar endpoints as much as possible to avoid
surprises for developers.
richvdh marked this conversation as resolved.
Show resolved Hide resolved


## Potential issues

Unlike for `/messages`, the `dir` parameter for `/relations` needs to be optional
(defaulting to `b`) to be backwards compatible with MSC2675 (and Synapse's
uhoreg marked this conversation as resolved.
Show resolved Hide resolved
legacy implementation).

`/messages` does have one additional parameter (`filter`) which would still not
be implemented for `/relations`. It is unclear if this parameter is useful here.
Comment on lines +84 to +85
Copy link
Member

Choose a reason for hiding this comment

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

let's leave it out until we have a usecase.



## Alternatives

The endpoint could be replaced with the `/event_relationships` API proposed in
[MSC2836](https://github.com/matrix-org/matrix-doc/pull/2836). That API would
add significant complexity over the current `/relations` API (e.g. arbitrary
of relations) and is not necessary to simply iterate events in the reverse ordering.


## Security considerations

None.

## Unstable prefix

Before standardization, `org.matrix.msc3715.dir` should be used in place of `dir`.