-
Notifications
You must be signed in to change notification settings - Fork 385
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
MSC 1794 - Federation v2 Invite API #1794
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b0adfc6
MSC 1794 - Federation v2 Invite API
erikjohnston 2109314
Apply suggestions from code review
erikjohnston c88c9c2
Update proposals/1794-federation-v2-invites.md
uhoreg b90ee6b
'invite_room_state' should be an array
erikjohnston ebf3717
Update proposals/1794-federation-v2-invites.md
richvdh 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 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,78 @@ | ||
# MSC 1794 - Federation v2 Invite API | ||
|
||
This proposal adds a new `/invite` API to federation that supports different | ||
room versions. | ||
|
||
## Motivation | ||
|
||
It is planned for future room versions to be able to change the format of events | ||
in various ways. To support this, all servers must know the room version | ||
whenever they need to parse an event. Currently the `/invite` API does not | ||
include the room version, so the target server would be unable to parse the event included in the payload. | ||
|
||
## Proposal | ||
|
||
Add a new version of the invite API under the prefix `/_matrix/federation/v2`, | ||
which has a payload of: | ||
|
||
``` | ||
PUT /_matrix/federation/v2/invite/<room_id>/<event_id> | ||
|
||
{ | ||
"room_version": <room_version>, | ||
"event": { ... }, | ||
"invite_room_state": [ ... ] | ||
} | ||
``` | ||
|
||
The differences between this and `v1` are: | ||
|
||
1. The payload in `v1` is the event, while in `v2` the event is instead placed | ||
under an `"event"` key. This is for consistency with other APIs, and to allow | ||
extra data to be added to the request payload separately from the event. | ||
2. A required field called `"room_version"` is added that specifies the room | ||
version. | ||
3. The `"invite_room_state"` is moved from the `unsigned` section of the event | ||
to a top level key. The key `invite_room_state` being in the `event.unsigned` | ||
was a hack due to point 1. above. | ||
|
||
|
||
The response is identical to `v1`, except that: | ||
|
||
1. If the receiving server does not support the given room version the | ||
appropriate incompatible-room-version error is returned, in the same way | ||
as e.g. for `/make_join` APIs. | ||
2. The response payload is no longer in the format of `[200, { ... }]`, and is | ||
instead simply the `{ ... }` portion. This fixes a historical accident to | ||
bring the invite API into line with the rest of the federation API. | ||
|
||
|
||
If a call to `v2` `/invite` results in an unrecognised request exception **AND** | ||
the room version is `1` or `2` then the sending server should retry the request | ||
with the `v1` API. | ||
|
||
|
||
## Alternatives | ||
|
||
|
||
### Reusing V1 API | ||
|
||
One alternative is to add a `room_version` query string parameter to the `v1` | ||
Half-Shot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
`/invite` API in a similar way as for the `/make_join` APIs. However, older | ||
servers would ignore the query string parameter while processing an incoming | ||
`/invite` request, resulting in the server attempting to parse the event in the | ||
old `v1` format. This would likely result in either a `400` or `500` response, | ||
which the sending server could interpret as the receiving server not supporting | ||
the room version. | ||
|
||
This method, however, is fragile and could easily mask legitimate `400` and | ||
`500` errors that are not due to not supporting the room version. | ||
|
||
|
||
### Using V1 API for V1 room versions | ||
|
||
Instead of all servers attempting to use the new API and falling back if the API | ||
is not found, servers could instead always use the current API for V1 and V2 | ||
rooms. | ||
|
||
However, this would not allow us to deprecate the `v1` API. |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on retrospect, I don't know if this is a good idea. We spent a lot of time going through the spec to make sure the
invite_room_state
was correctly documented to be under the unsigned object. Given this is for s2s communications though, this is probably fine.