Add option to skip deleted members when syncing members. Fixes #192

This commit is contained in:
Tulir Asokan
2019-02-14 01:07:50 +02:00
parent 346090f7dc
commit 17b711d097
3 changed files with 8 additions and 2 deletions
+2
View File
@@ -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
+1
View File
@@ -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")
+5 -2
View File
@@ -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)