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

Commit 4b1002c

Browse files
committed
Convert MemberSummary to attrs.
1 parent 9d4d3a1 commit 4b1002c

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

synapse/handlers/sync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ async def compute_summary(
701701
name_id = state_ids.get((EventTypes.Name, ""))
702702
canonical_alias_id = state_ids.get((EventTypes.CanonicalAlias, ""))
703703

704-
summary = {}
704+
summary: JsonDict = {}
705705
empty_ms = MemberSummary([], 0)
706706

707707
# TODO: only send these when they change.

synapse/storage/roommember.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
# limitations under the License.
1515

1616
import logging
17-
from collections import namedtuple
18-
from typing import Optional
17+
from typing import List, Optional, Tuple
1918

2019
import attr
2120

@@ -45,7 +44,10 @@ class ProfileInfo:
4544
display_name: Optional[str]
4645

4746

48-
# "members" points to a truncated list of (user_id, event_id) tuples for users of
49-
# a given membership type, suitable for use in calculating heroes for a room.
50-
# "count" points to the total numberr of users of a given membership type.
51-
MemberSummary = namedtuple("MemberSummary", ("members", "count"))
47+
@attr.s(slots=True, frozen=True, auto_attribs=True)
48+
class MemberSummary:
49+
# A truncated list of (user_id, event_id) tuples for users of a given
50+
# membership type, suitable for use in calculating heroes for a room.
51+
members: List[Tuple[str, str]]
52+
# The total number of users of a given membership type.
53+
count: int

0 commit comments

Comments
 (0)