This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Implement MSC 1813 - Add room version to make APIs #4447
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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 |
---|---|---|
|
@@ -25,14 +25,19 @@ | |
|
||
from twisted.internet import defer | ||
|
||
from synapse.api.constants import KNOWN_ROOM_VERSIONS, EventTypes, Membership | ||
from synapse.api.constants import ( | ||
KNOWN_ROOM_VERSIONS, | ||
EventTypes, | ||
Membership, | ||
RoomVersions, | ||
) | ||
from synapse.api.errors import ( | ||
CodeMessageException, | ||
FederationDeniedError, | ||
HttpResponseException, | ||
SynapseError, | ||
) | ||
from synapse.events import builder | ||
from synapse.events import builder, room_version_to_event_format | ||
from synapse.federation.federation_base import FederationBase, event_from_pdu_json | ||
from synapse.util import logcontext, unwrapFirstError | ||
from synapse.util.caches.expiringcache import ExpiringCache | ||
|
@@ -536,8 +541,9 @@ def make_membership_event(self, destinations, room_id, user_id, membership, | |
params (dict[str, str|Iterable[str]]): Query parameters to include in the | ||
request. | ||
Return: | ||
Deferred: resolves to a tuple of (origin (str), event (object)) | ||
where origin is the remote homeserver which generated the event. | ||
Deferred[tuple[str, dict, int]]: resolves to a tuple of | ||
`(origin, event, event_format)` where origin is the remote | ||
homeserver which generated the event. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you clarify that |
||
|
||
Fails with a ``SynapseError`` if the chosen remote server | ||
returns a 300/400 code. | ||
|
@@ -557,6 +563,11 @@ def send_request(destination): | |
destination, room_id, user_id, membership, params, | ||
) | ||
|
||
# Note: If not supplied, the room version may be either v1 or v2, | ||
# however either way the event format version will be v1. | ||
room_version = ret.get("room_version", RoomVersions.V1) | ||
event_format = room_version_to_event_format(room_version) | ||
|
||
pdu_dict = ret.get("event", None) | ||
if not isinstance(pdu_dict, dict): | ||
raise InvalidResponseError("Bad 'event' field in response") | ||
|
@@ -574,7 +585,7 @@ def send_request(destination): | |
ev = builder.EventBuilder(pdu_dict) | ||
|
||
defer.returnValue( | ||
(destination, ev) | ||
(destination, ev, event_format) | ||
) | ||
|
||
return self._try_destination_list( | ||
|
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
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
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.
need to raise something here