From 83d457f2b3e9f314b1d0b2b9f71178b2d249ce99 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 29 Oct 2021 20:15:24 +0300 Subject: [PATCH] Ignore ChannelParticipantBanned in participant list. Fixes #635 --- mautrix_telegram/portal/matrix.py | 3 ++- mautrix_telegram/portal/metadata.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mautrix_telegram/portal/matrix.py b/mautrix_telegram/portal/matrix.py index 9ec59dbc..1b2b68a9 100644 --- a/mautrix_telegram/portal/matrix.py +++ b/mautrix_telegram/portal/matrix.py @@ -421,7 +421,8 @@ class PortalMatrix(BasePortal, ABC): await self._handle_matrix_file(sender_id, event_id, space, client, content, reply_to, caption_content) else: - self.log.trace("Unhandled Matrix event: %s", content) + self.log.debug("Didn't handle Matrix event {event_id} due to unknown msgtype {content.msgtype}") + self.log.trace("Unhandled Matrix event content: %s", content) async def handle_matrix_unpin_all(self, sender: 'u.User', pin_event_id: EventID) -> None: await sender.client(UnpinAllMessagesRequest(peer=self.peer)) diff --git a/mautrix_telegram/portal/metadata.py b/mautrix_telegram/portal/metadata.py index 02624be3..27217dc0 100644 --- a/mautrix_telegram/portal/metadata.py +++ b/mautrix_telegram/portal/metadata.py @@ -27,7 +27,7 @@ from telethon.tl.types import ( PhotoEmpty, InputChannel, InputUser, ChatPhotoEmpty, PeerUser, Photo, TypeChat, TypeInputPeer, TypeUser, User, InputPeerPhotoFileLocation, ChatParticipantAdmin, ChannelParticipantAdmin, ChatParticipantCreator, ChannelParticipantCreator, UserProfilePhoto, UserProfilePhotoEmpty, - InputPeerUser) + InputPeerUser, ChannelParticipantBanned) from mautrix.errors import MForbidden from mautrix.types import (RoomID, UserID, RoomCreatePreset, EventType, Membership, @@ -797,7 +797,8 @@ class PortalMetadata(BasePortal, ABC): @staticmethod def _filter_participants(users: List[TypeUser], participants: List[TypeParticipant] ) -> Iterable[TypeUser]: - participant_map = {part.user_id: part for part in participants} + participant_map = {part.user_id: part for part in participants + if not isinstance(part, ChannelParticipantBanned)} for user in users: try: user.participant = participant_map[user.id]