From 0915bb9402676cc2d1bc3c4a5e49b25d4c7d6d2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tadeusz=20So=C5=9Bnierz?= Date: Wed, 27 Oct 2021 14:33:08 +0200 Subject: [PATCH] Make max_initial_member_sync work for Chats as well as Channels --- mautrix_telegram/portal/metadata.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mautrix_telegram/portal/metadata.py b/mautrix_telegram/portal/metadata.py index 02624be3..87cbeaf2 100644 --- a/mautrix_telegram/portal/metadata.py +++ b/mautrix_telegram/portal/metadata.py @@ -833,15 +833,16 @@ async def _get_channel_users(self, user: 'AbstractUser', entity: InputChannel, l async def _get_users(self, user: 'AbstractUser', entity: Union[TypeInputPeer, InputUser, TypeChat, TypeUser, InputChannel] ) -> List[TypeUser]: + limit = self.max_initial_member_sync if self.peer_type == "chat": chat = await user.client(GetFullChatRequest(chat_id=self.tgid)) - return list(self._filter_participants(chat.users, - chat.full_chat.participants.participants)) + return list( + self._filter_participants(chat.users, chat.full_chat.participants.participants) + )[:limit] elif self.peer_type == "channel": if not self.megagroup and not self.sync_channel_members: return [] - limit = self.max_initial_member_sync if limit == 0: return []