1
0

Fix accepting an invite.

This commit is contained in:
Patrick Cloke
2023-07-18 11:33:46 -04:00
parent ab75a7d2ac
commit b04530ebd3
3 changed files with 19 additions and 4 deletions

View File

@@ -89,6 +89,8 @@ class EventBuilder:
# TODO(LM) If Synapse is acting as a hub-server this should be itself.
hub_server: Optional[str] = None
_lpdu_hashes: Optional[str] = None
_lpdu_signatures: Optional[str] = None
internal_metadata: _EventInternalMetadata = attr.Factory(
lambda: _EventInternalMetadata({})
@@ -187,7 +189,7 @@ class EventBuilder:
if self._origin_server_ts is not None:
event_dict["origin_server_ts"] = self._origin_server_ts
return create_local_event_from_event_dict(
event = create_local_event_from_event_dict(
clock=self._clock,
hostname=self._hostname,
signing_key=self._signing_key,
@@ -196,6 +198,13 @@ class EventBuilder:
internal_metadata_dict=self.internal_metadata.get_dict(),
)
if self.room_version.linearized_matrix and self._lpdu_hashes:
event.hashes["lpdu"] = self._lpdu_hashes
if self.room_version.linearized_matrix and self._lpdu_signatures:
event.signatures.update(self._lpdu_signatures)
return event
class EventBuilderFactory:
def __init__(self, hs: "HomeServer"):
@@ -237,6 +246,8 @@ class EventBuilderFactory:
redacts=key_values.get("redacts", None),
origin_server_ts=key_values.get("origin_server_ts", None),
hub_server=key_values.get("hub_server", None),
lpdu_hashes=key_values.get("lpdu_hashes", None),
lpdu_signatures=key_values.get("lpdu_signatures", None),
)

View File

@@ -1060,6 +1060,7 @@ class FederationServer(FederationBase):
"origin_server_ts",
"content",
"hashes",
"signatures",
),
)
@@ -1069,12 +1070,15 @@ class FederationServer(FederationBase):
raise SynapseError(400, f"LPDU contained {field}", Codes.BAD_JSON)
# Hashes must contain (only) "lpdu".
if not isinstance(lpdu_json["hashes"], collections.abc.Mapping):
hashes = lpdu_json.pop("hashes")
if not isinstance(hashes, collections.abc.Mapping):
raise SynapseError(400, "Invalid hashes", Codes.BAD_JSON)
if lpdu_json["hashes"].keys() != {"lpdu"}:
if hashes.keys() != {"lpdu"}:
raise SynapseError(
400, "hashes must contain exactly one key: 'lpdu'", Codes.BAD_JSON
)
lpdu_json["lpdu_hashes"] = hashes["lpdu"]
lpdu_json["lpdu_signatures"] = lpdu_json.pop("signatures")
# Validate that the JSON conforms to the specification.
if room_version.strict_canonicaljson:

View File

@@ -625,7 +625,7 @@ class FederationUnstableSendJoinServlet(BaseFederationServerServlet):
return 200, {
"event": result["event"],
"state": result["state"],
"auth_chain": result["auth_chain}"],
"auth_chain": result["auth_chain"],
}