Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Prep work for the updated spaces summary #10527

Merged
merged 3 commits into from
Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/10527.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prepare for the new spaces summary endpoint (updates to [MSC2946](https://github.com/matrix-org/matrix-doc/pull/2946)).
18 changes: 9 additions & 9 deletions synapse/federation/federation_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@ async def send_request(destination: str) -> FederationSpaceSummaryResult:
)


@attr.s(frozen=True, slots=True)
@attr.s(frozen=True, slots=True, auto_attribs=True)
class FederationSpaceSummaryEventResult:
"""Represents a single event in the result of a successful get_space_summary call.

Expand All @@ -1299,12 +1299,12 @@ class FederationSpaceSummaryEventResult:
object attributes.
"""

event_type = attr.ib(type=str)
state_key = attr.ib(type=str)
via = attr.ib(type=Sequence[str])
event_type: str
state_key: str
via: Sequence[str]

# the raw data, including the above keys
data = attr.ib(type=JsonDict)
data: JsonDict

@classmethod
def from_json_dict(cls, d: JsonDict) -> "FederationSpaceSummaryEventResult":
Expand Down Expand Up @@ -1335,15 +1335,15 @@ def from_json_dict(cls, d: JsonDict) -> "FederationSpaceSummaryEventResult":
if any(not isinstance(v, str) for v in via):
raise ValueError("Invalid event: 'via' must be a list of strings")

return cls(event_type, state_key, via, d)
return cls(event_type, room_id, state_key, via, d)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has ended up in the wrong commit, but nm

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good shout, sorry about that. I had much rebasing in these branches... 😢



@attr.s(frozen=True, slots=True)
@attr.s(frozen=True, slots=True, auto_attribs=True)
class FederationSpaceSummaryResult:
"""Represents the data returned by a successful get_space_summary call."""

rooms = attr.ib(type=Sequence[JsonDict])
events = attr.ib(type=Sequence[FederationSpaceSummaryEventResult])
rooms: Sequence[JsonDict]
events: Sequence[FederationSpaceSummaryEventResult]

@classmethod
def from_json_dict(cls, d: JsonDict) -> "FederationSpaceSummaryResult":
Expand Down
6 changes: 3 additions & 3 deletions synapse/handlers/space_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,10 +606,10 @@ async def _get_child_events(self, room_id: str) -> Iterable[EventBase]:
return sorted(filter(_has_valid_via, events), key=_child_events_comparison_key)


@attr.s(frozen=True, slots=True)
@attr.s(frozen=True, slots=True, auto_attribs=True)
class _RoomQueueEntry:
room_id = attr.ib(type=str)
via = attr.ib(type=Sequence[str])
room_id: str
via: Sequence[str]


def _has_valid_via(e: EventBase) -> bool:
Expand Down