mirror of
https://github.com/element-hq/synapse
synced 2024-08-20 20:10:20 +00:00
Fix room_version
in on_invite_request
flow (#6827)
I messed this up a bit in #6805, but fortunately we weren't actually doing anything with the room_version so it didn't matter that it was a str not a RoomVersion.
This commit is contained in:
parent
68ef7ebbef
commit
b0d112e78b
3 changed files with 11 additions and 7 deletions
1
changelog.d/6827.misc
Normal file
1
changelog.d/6827.misc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Refactoring work in preparation for changing the event redaction algorithm.
|
|
@ -54,7 +54,7 @@ from synapse.replication.http.federation import (
|
||||||
ReplicationFederationSendEduRestServlet,
|
ReplicationFederationSendEduRestServlet,
|
||||||
ReplicationGetQueryRestServlet,
|
ReplicationGetQueryRestServlet,
|
||||||
)
|
)
|
||||||
from synapse.types import get_domain_from_id
|
from synapse.types import JsonDict, get_domain_from_id
|
||||||
from synapse.util import glob_to_regex, unwrapFirstError
|
from synapse.util import glob_to_regex, unwrapFirstError
|
||||||
from synapse.util.async_helpers import Linearizer, concurrently_execute
|
from synapse.util.async_helpers import Linearizer, concurrently_execute
|
||||||
from synapse.util.caches.response_cache import ResponseCache
|
from synapse.util.caches.response_cache import ResponseCache
|
||||||
|
@ -396,20 +396,23 @@ class FederationServer(FederationBase):
|
||||||
time_now = self._clock.time_msec()
|
time_now = self._clock.time_msec()
|
||||||
return {"event": pdu.get_pdu_json(time_now), "room_version": room_version}
|
return {"event": pdu.get_pdu_json(time_now), "room_version": room_version}
|
||||||
|
|
||||||
async def on_invite_request(self, origin, content, room_version):
|
async def on_invite_request(
|
||||||
if room_version not in KNOWN_ROOM_VERSIONS:
|
self, origin: str, content: JsonDict, room_version_id: str
|
||||||
|
):
|
||||||
|
room_version = KNOWN_ROOM_VERSIONS.get(room_version_id)
|
||||||
|
if not room_version:
|
||||||
raise SynapseError(
|
raise SynapseError(
|
||||||
400,
|
400,
|
||||||
"Homeserver does not support this room version",
|
"Homeserver does not support this room version",
|
||||||
Codes.UNSUPPORTED_ROOM_VERSION,
|
Codes.UNSUPPORTED_ROOM_VERSION,
|
||||||
)
|
)
|
||||||
|
|
||||||
format_ver = room_version_to_event_format(room_version)
|
format_ver = room_version.event_format
|
||||||
|
|
||||||
pdu = event_from_pdu_json(content, format_ver)
|
pdu = event_from_pdu_json(content, format_ver)
|
||||||
origin_host, _ = parse_server_name(origin)
|
origin_host, _ = parse_server_name(origin)
|
||||||
await self.check_server_matches_acl(origin_host, pdu.room_id)
|
await self.check_server_matches_acl(origin_host, pdu.room_id)
|
||||||
pdu = await self._check_sigs_and_hash(room_version, pdu)
|
pdu = await self._check_sigs_and_hash(room_version.identifier, pdu)
|
||||||
ret_pdu = await self.handler.on_invite_request(origin, pdu, room_version)
|
ret_pdu = await self.handler.on_invite_request(origin, pdu, room_version)
|
||||||
time_now = self._clock.time_msec()
|
time_now = self._clock.time_msec()
|
||||||
return {"event": ret_pdu.get_pdu_json(time_now)}
|
return {"event": ret_pdu.get_pdu_json(time_now)}
|
||||||
|
|
|
@ -579,7 +579,7 @@ class FederationV1InviteServlet(BaseFederationServlet):
|
||||||
# state resolution algorithm, and we don't use that for processing
|
# state resolution algorithm, and we don't use that for processing
|
||||||
# invites
|
# invites
|
||||||
content = await self.handler.on_invite_request(
|
content = await self.handler.on_invite_request(
|
||||||
origin, content, room_version=RoomVersions.V1.identifier
|
origin, content, room_version_id=RoomVersions.V1.identifier
|
||||||
)
|
)
|
||||||
|
|
||||||
# V1 federation API is defined to return a content of `[200, {...}]`
|
# V1 federation API is defined to return a content of `[200, {...}]`
|
||||||
|
@ -606,7 +606,7 @@ class FederationV2InviteServlet(BaseFederationServlet):
|
||||||
event.setdefault("unsigned", {})["invite_room_state"] = invite_room_state
|
event.setdefault("unsigned", {})["invite_room_state"] = invite_room_state
|
||||||
|
|
||||||
content = await self.handler.on_invite_request(
|
content = await self.handler.on_invite_request(
|
||||||
origin, event, room_version=room_version
|
origin, event, room_version_id=room_version
|
||||||
)
|
)
|
||||||
return 200, content
|
return 200, content
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue