mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-15 03:33:51 +01:00
Correct field name for stripped state events when knocking. knock_state_events
-> knock_room_state
(#14102)
This commit is contained in:
parent
c152e58116
commit
9c23442ac9
4 changed files with 26 additions and 6 deletions
1
changelog.d/14102.bugfix
Normal file
1
changelog.d/14102.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Fix a bug introduced in Synapse v1.37.0 in which an incorrect key name was used for sending and receiving room metadata when knocking on a room.
|
|
@ -1294,7 +1294,7 @@ class FederationClient(FederationBase):
|
||||||
return resp[1]
|
return resp[1]
|
||||||
|
|
||||||
async def send_knock(self, destinations: List[str], pdu: EventBase) -> JsonDict:
|
async def send_knock(self, destinations: List[str], pdu: EventBase) -> JsonDict:
|
||||||
"""Attempts to send a knock event to given a list of servers. Iterates
|
"""Attempts to send a knock event to a given list of servers. Iterates
|
||||||
through the list until one attempt succeeds.
|
through the list until one attempt succeeds.
|
||||||
|
|
||||||
Doing so will cause the remote server to add the event to the graph,
|
Doing so will cause the remote server to add the event to the graph,
|
||||||
|
|
|
@ -824,7 +824,14 @@ class FederationServer(FederationBase):
|
||||||
context, self._room_prejoin_state_types
|
context, self._room_prejoin_state_types
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return {"knock_state_events": stripped_room_state}
|
return {
|
||||||
|
"knock_room_state": stripped_room_state,
|
||||||
|
# Since v1.37, Synapse incorrectly used "knock_state_events" for this field.
|
||||||
|
# Thus, we also populate a 'knock_state_events' with the same content to
|
||||||
|
# support old instances.
|
||||||
|
# See https://github.com/matrix-org/synapse/issues/14088.
|
||||||
|
"knock_state_events": stripped_room_state,
|
||||||
|
}
|
||||||
|
|
||||||
async def _on_send_membership_event(
|
async def _on_send_membership_event(
|
||||||
self, origin: str, content: JsonDict, membership_type: str, room_id: str
|
self, origin: str, content: JsonDict, membership_type: str, room_id: str
|
||||||
|
|
|
@ -781,15 +781,27 @@ class FederationHandler:
|
||||||
|
|
||||||
# Send the signed event back to the room, and potentially receive some
|
# Send the signed event back to the room, and potentially receive some
|
||||||
# further information about the room in the form of partial state events
|
# further information about the room in the form of partial state events
|
||||||
stripped_room_state = await self.federation_client.send_knock(
|
knock_response = await self.federation_client.send_knock(target_hosts, event)
|
||||||
target_hosts, event
|
|
||||||
)
|
|
||||||
|
|
||||||
# Store any stripped room state events in the "unsigned" key of the event.
|
# Store any stripped room state events in the "unsigned" key of the event.
|
||||||
# This is a bit of a hack and is cribbing off of invites. Basically we
|
# This is a bit of a hack and is cribbing off of invites. Basically we
|
||||||
# store the room state here and retrieve it again when this event appears
|
# store the room state here and retrieve it again when this event appears
|
||||||
# in the invitee's sync stream. It is stripped out for all other local users.
|
# in the invitee's sync stream. It is stripped out for all other local users.
|
||||||
event.unsigned["knock_room_state"] = stripped_room_state["knock_state_events"]
|
stripped_room_state = (
|
||||||
|
knock_response.get("knock_room_state")
|
||||||
|
# Since v1.37, Synapse incorrectly used "knock_state_events" for this field.
|
||||||
|
# Thus, we also check for a 'knock_state_events' to support old instances.
|
||||||
|
# See https://github.com/matrix-org/synapse/issues/14088.
|
||||||
|
or knock_response.get("knock_state_events")
|
||||||
|
)
|
||||||
|
|
||||||
|
if stripped_room_state is None:
|
||||||
|
raise KeyError(
|
||||||
|
"Missing 'knock_room_state' (or legacy 'knock_state_events') field in "
|
||||||
|
"send_knock response"
|
||||||
|
)
|
||||||
|
|
||||||
|
event.unsigned["knock_room_state"] = stripped_room_state
|
||||||
|
|
||||||
context = EventContext.for_outlier(self._storage_controllers)
|
context = EventContext.for_outlier(self._storage_controllers)
|
||||||
stream_id = await self._federation_event_handler.persist_events_and_notify(
|
stream_id = await self._federation_event_handler.persist_events_and_notify(
|
||||||
|
|
Loading…
Reference in a new issue