|  | 
| 14 | 14 | # limitations under the License. | 
| 15 | 15 | 
 | 
| 16 | 16 | import logging | 
| 17 |  | -from collections import namedtuple | 
|  | 17 | +from typing import List, Optional, Tuple | 
|  | 18 | + | 
|  | 19 | +import attr | 
|  | 20 | + | 
|  | 21 | +from synapse.types import PersistedEventPosition | 
| 18 | 22 | 
 | 
| 19 | 23 | logger = logging.getLogger(__name__) | 
| 20 | 24 | 
 | 
| 21 | 25 | 
 | 
| 22 |  | -RoomsForUser = namedtuple( | 
| 23 |  | -    "RoomsForUser", ("room_id", "sender", "membership", "event_id", "stream_ordering") | 
| 24 |  | -) | 
|  | 26 | +@attr.s(slots=True, frozen=True, weakref_slot=True, auto_attribs=True) | 
|  | 27 | +class RoomsForUser: | 
|  | 28 | +    room_id: str | 
|  | 29 | +    sender: str | 
|  | 30 | +    membership: str | 
|  | 31 | +    event_id: str | 
|  | 32 | +    stream_ordering: int | 
|  | 33 | + | 
|  | 34 | + | 
|  | 35 | +@attr.s(slots=True, frozen=True, weakref_slot=True, auto_attribs=True) | 
|  | 36 | +class GetRoomsForUserWithStreamOrdering: | 
|  | 37 | +    room_id: str | 
|  | 38 | +    event_pos: PersistedEventPosition | 
| 25 | 39 | 
 | 
| 26 |  | -GetRoomsForUserWithStreamOrdering = namedtuple( | 
| 27 |  | -    "GetRoomsForUserWithStreamOrdering", ("room_id", "event_pos") | 
| 28 |  | -) | 
| 29 | 40 | 
 | 
|  | 41 | +@attr.s(slots=True, frozen=True, weakref_slot=True, auto_attribs=True) | 
|  | 42 | +class ProfileInfo: | 
|  | 43 | +    avatar_url: Optional[str] | 
|  | 44 | +    display_name: Optional[str] | 
| 30 | 45 | 
 | 
| 31 |  | -# We store this using a namedtuple so that we save about 3x space over using a | 
| 32 |  | -# dict. | 
| 33 |  | -ProfileInfo = namedtuple("ProfileInfo", ("avatar_url", "display_name")) | 
| 34 | 46 | 
 | 
| 35 |  | -# "members" points to a truncated list of (user_id, event_id) tuples for users of | 
| 36 |  | -# a given membership type, suitable for use in calculating heroes for a room. | 
| 37 |  | -# "count" points to the total numberr of users of a given membership type. | 
| 38 |  | -MemberSummary = namedtuple("MemberSummary", ("members", "count")) | 
|  | 47 | +@attr.s(slots=True, frozen=True, weakref_slot=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