diff --git a/example-config.yaml b/example-config.yaml index cfccc342..e1c46fa9 100644 --- a/example-config.yaml +++ b/example-config.yaml @@ -104,6 +104,8 @@ bridge: # If no channel admins have logged into the bridge, the bridge won't be able to sync the member # list regardless of this setting. sync_channel_members: true + # Whether or not to skip deleted members when syncing members. + skip_deleted_members: true # Whether or not to automatically synchronize contacts and chats of Matrix users logged into # their Telegram account at startup. startup_sync: true diff --git a/mautrix_telegram/config.py b/mautrix_telegram/config.py index 7d283ff5..98ab68bb 100644 --- a/mautrix_telegram/config.py +++ b/mautrix_telegram/config.py @@ -202,6 +202,7 @@ class Config(DictWithRecursion): copy("bridge.bot_messages_as_notices") copy("bridge.max_initial_member_sync") copy("bridge.sync_channel_members") + copy("bridge.skip_deleted_members") copy("bridge.startup_sync") copy("bridge.sync_dialog_limit") copy("bridge.sync_matrix_state") diff --git a/mautrix_telegram/portal.py b/mautrix_telegram/portal.py index 7d4b05ec..e2a41c88 100644 --- a/mautrix_telegram/portal.py +++ b/mautrix_telegram/portal.py @@ -461,13 +461,16 @@ class Portal: self.bot.add_chat(self.tgid, self.peer_type) return - user = u.User.get_by_tgid(bot.id) + user = u.User.get_by_tgid(TelegramID(bot.id)) if user and user.is_bot: user.register_portal(self) async def sync_telegram_users(self, source: 'AbstractUser', users: List[User]) -> None: allowed_tgids = set() + skip_deleted = config["bridge.skip_deleted_members"] for entity in users: + if skip_deleted and entity.deleted: + continue puppet = p.Puppet.get(TelegramID(entity.id)) if entity.bot: self.add_bot_chat(entity) @@ -475,7 +478,7 @@ class Portal: await puppet.intent.ensure_joined(self.mxid) await puppet.update_info(source, entity) - user = u.User.get_by_tgid(entity.id) + user = u.User.get_by_tgid(TelegramID(entity.id)) if user: await self.invite_to_matrix(user.mxid)