diff --git a/TODO.md b/TODO.md index 7809968b..bb58c4c5 100644 --- a/TODO.md +++ b/TODO.md @@ -1,3 +1,4 @@ +- see how the member list reacts to a huge unencrypted room - "rejoin" leftbanner button if room is public - daybreak color - html links color diff --git a/src/python/events/users.py b/src/python/events/users.py index 586cd6be..5596946e 100644 --- a/src/python/events/users.py +++ b/src/python/events/users.py @@ -3,10 +3,11 @@ from datetime import datetime from enum import Enum -from typing import Optional from dataclasses import dataclass, field +from nio.rooms import MatrixUser + from .event import Event # Logged-in accounts @@ -31,6 +32,15 @@ class UserUpdated(Event): status_message: str = "" + @classmethod + def from_nio(cls, user: MatrixUser) -> "UserUpdated": + return cls( + user_id = user.user_id, + display_name = user.display_name, + avatar_url = user.avatar_url, + ) + + # Devices class Trust(Enum): diff --git a/src/python/matrix_client.py b/src/python/matrix_client.py index 3c2d63c5..26669a0e 100644 --- a/src/python/matrix_client.py +++ b/src/python/matrix_client.py @@ -202,13 +202,23 @@ class MatrixClient(nio.AsyncClient): up = rooms.RoomUpdated.from_nio for room_id, info in resp.rooms.invite.items(): - up(self.user_id, "Invites", self.invited_rooms[room_id], info) + room = self.invited_rooms[room_id] + + for member in room.users.values(): + users.UserUpdated.from_nio(member) + + up(self.user_id, "Invites", room, info) for room_id, info in resp.rooms.join.items(): + room = self.rooms[room_id] + + for member in room.users.values(): + users.UserUpdated.from_nio(member) + if room_id not in self.backend.past_tokens: self.backend.past_tokens[room_id] = info.timeline.prev_batch - up(self.user_id, "Rooms", self.rooms[room_id], info) + up(self.user_id, "Rooms", room, info) for room_id, info in resp.rooms.leave.items(): # TODO: handle in nio, these are rooms that were left before @@ -354,14 +364,6 @@ class MatrixClient(nio.AsyncClient): async def onRoomMemberEvent(self, room, ev, from_past=False) -> None: - if not from_past and ev.membership != "leave": - users.UserUpdated( - user_id = ev.state_key, - display_name = ev.content["displayname"] or "", - avatar_url = ev.content["avatar_url"] or "", - status_message = "", # TODO - ) - co = await self.get_room_member_event_content(ev) if co is not None: