mirror of
https://mau.dev/maunium/synapse.git
synced 2024-11-16 06:51:46 +01:00
Fix handling room versions
This commit is contained in:
parent
1357a75592
commit
ce02e755c1
2 changed files with 10 additions and 2 deletions
|
@ -683,7 +683,7 @@ class FederationHandler(BaseHandler, FederationBase):
|
|||
async def _validate_forwarded_event(self, event: EventBase) -> Tuple[bool, Optional[str]]:
|
||||
try:
|
||||
source_evt_dict = {**event.content[self._forwarded_key]}
|
||||
room_version = source_evt_dict["unsigned"]["room_version"]
|
||||
room_version_identifier = source_evt_dict["unsigned"]["room_version"]
|
||||
source_evt_dict["type"] = event.type
|
||||
source_evt_dict["content"] = {**event.content}
|
||||
del source_evt_dict["unsigned"]
|
||||
|
@ -691,11 +691,18 @@ class FederationHandler(BaseHandler, FederationBase):
|
|||
except (KeyError, TypeError):
|
||||
logger.exception("Failed to read forward data")
|
||||
return False, None
|
||||
|
||||
room_version = KNOWN_ROOM_VERSIONS.get(room_version_identifier)
|
||||
if not room_version:
|
||||
# We don't support the source room version, so we can't verify the event :(
|
||||
return False, None
|
||||
|
||||
try:
|
||||
source_evt = event_from_pdu_json(source_evt_dict, room_version)
|
||||
except SynapseError:
|
||||
logger.exception("Failed to parse forward data")
|
||||
return False, None
|
||||
|
||||
try:
|
||||
checked_evt = await self._check_sigs_and_hash(room_version, source_evt)
|
||||
# _check_sigs_and_hash returns a redacted event if hash validation failed and
|
||||
|
|
|
@ -85,8 +85,9 @@ class RoomEventForwardServlet(RestServlet):
|
|||
errcode=self._err_not_forwardable)
|
||||
elif not has_forward_meta:
|
||||
content[self._data_key] = event_dict
|
||||
room_version = await self.store.get_room_version(event.room_id)
|
||||
content[self._data_key]["unsigned"] = {
|
||||
"room_version": await self.store.get_room_version(event.room_id),
|
||||
"room_version": room_version.identifier,
|
||||
# TODO add sender profile info here
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue