Skip to content

Commit 8ad82ce

Browse files
committed
Add permalink routing through ?via parameters on matrix.to URIs
Spec for [MSC1704](#1704) Reference implementations: * Original: matrix-org/matrix-react-sdk#2250 * Modern recommendations: https://github.com/matrix-org/matrix-react-sdk/blob/2ca281f6b7b735bc96945370584c5cb1b5f7e1f1/src/matrix-to.js#L29-L70 The only deviation from the original MSC is the recommendation for which servers to pick. The original MSC failed to consider server ACLs and IP addresses correctly, and during implementation it was realized that both of these cases should be handled. The core principles of the original MSC are left unaltered.
1 parent 1c5ec68 commit 8ad82ce

File tree

1 file changed

+55
-6
lines changed

1 file changed

+55
-6
lines changed

specification/appendices/identifier_grammar.rst

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,16 @@ in the room's history (a permalink).
311311
A matrix.to URI has the following format, based upon the specification defined
312312
in RFC 3986:
313313

314-
https://matrix.to/#/<identifier>/<extra parameter>
314+
https://matrix.to/#/<identifier>/<extra parameter>?<additional arguments>
315315

316316
The identifier may be a room ID, room alias, user ID, or group ID. The extra
317317
parameter is only used in the case of permalinks where an event ID is referenced.
318318
The matrix.to URI, when referenced, must always start with ``https://matrix.to/#/``
319319
followed by the identifier.
320320

321+
The ``<additional arguments>`` and the preceeding question mark are optional and
322+
only apply in certain circumstances, documented below.
323+
321324
Clients should not rely on matrix.to URIs falling back to a web server if accessed
322325
and instead should perform some sort of action within the client. For example, if
323326
the user were to click on a matrix.to URI for a room alias, the client may open
@@ -331,7 +334,7 @@ Examples of matrix.to URIs are:
331334
* Room alias: ``https://matrix.to/#/%23somewhere%3Aexample.org``
332335
* Room: ``https://matrix.to/#/!somewhere%3Aexample.org``
333336
* Permalink by room: ``https://matrix.to/#/!somewhere%3Aexample.org/%24event%3Aexample.org``
334-
* Permalink by room alias: ``https://matrix.to/#/#somewhere:example.org/%24event%3Aexample.org``
337+
* Permalink by room alias: ``https://matrix.to/#/%23somewhere:example.org/%24event%3Aexample.org``
335338
* User: ``https://matrix.to/#/%40alice%3Aexample.org``
336339
* Group: ``https://matrix.to/#/%2Bexample%3Aexample.org``
337340

@@ -345,7 +348,53 @@ Examples of matrix.to URIs are:
345348
appearing due to some `room versions <index.html#room-versions>`_. These slashes
346349
should normally be encoded when producing matrix.to URIs, however.
347350

348-
.. Note::
349-
Room ID permalinks are unroutable as there is no reliable domain to send requests
350-
to upon receipt of the permalink. Clients should do their best route Room IDs to
351-
where they need to go, however they should also be aware of `issue #1579 <https://github.com/matrix-org/matrix-doc/issues/1579>`_.
351+
Routing
352+
<<<<<<<
353+
354+
Room IDs are not routable on their own as there is no reliable domain to send requests
355+
to. This is partially mitigated with the addition of a ``via`` argument on a matrix.to
356+
URI, however the problem of routability is still present. Clients should do their best
357+
to route Room IDs to where they need to go, however they should also be aware of
358+
`issue #1579 <https://github.com/matrix-org/matrix-doc/issues/1579>`_.
359+
360+
A room (or room permalink) which isn't using a room alias should supply at least one
361+
server using ``via`` in the ``<additional arguments>``, like so:
362+
``https://matrix.to/!somewhere%3Aexample.org?via=example.org&via=alt.example.org``. The
363+
parameter can be supplied multiple times to specify multiple servers to try.
364+
365+
The values of ``via`` are intended to be passed along as the ``server_name`` parameters
366+
on the Client Server ``/join`` API.
367+
368+
When generating room links and permalinks, the application should pick servers which
369+
have a high probability of being in the room in the distant future. How these servers
370+
are picked is left as an implementation detail, however the current recommendation is
371+
to pick 3 unique servers based on the following criteria:
372+
373+
* The first server should be the server of the highest power level user in the room,
374+
provided they are at least power level 50. If no user meets this criteria, pick the
375+
most popular server in the room (most joined users). The rationale for not picking
376+
users with power levels under 50 is that they are unlikely to be around into the
377+
distant future while higher ranking users (and therefore servers) are less likely
378+
to give up their power and move somewhere else. Most rooms in the public federation
379+
have a power level 100 user and have not deviated from the default structure where
380+
power level 50 users have moderator-style privileges.
381+
382+
* The second server should be the next highest server by population, or the first
383+
highest by population if the first server was based on a user's power level. The
384+
rationale for picking popular servers is that the server is unlikely to be removed
385+
as the room naturally grows in membership due to that server joining users. The
386+
server could be refused participation in the future due to server ACLs or similar,
387+
however the chance of that happening to a server which is organically joining the
388+
room is unlikely.
389+
390+
* The third server should be the next highest server by population.
391+
392+
* Servers which are blocked due to server ACLs should never be chosen.
393+
394+
* Servers which are IP addresses should never be chosen. Servers which use a domain
395+
name are less likely to be unroutable in the future whereas IP addresses cannot be
396+
pointed to a different location and therefore higher risk options.
397+
398+
* All 3 servers should be unique from each other. If the room does not have enough users
399+
to supply 3 servers, the application should only specify the servers it can. For example,
400+
a room with only 2 users in it would result in maximum 2 ``via`` parameters.

0 commit comments

Comments
 (0)