Add option to skip deleted members when syncing members. Fixes #192
This commit is contained in:
@@ -104,6 +104,8 @@ bridge:
|
|||||||
# If no channel admins have logged into the bridge, the bridge won't be able to sync the member
|
# If no channel admins have logged into the bridge, the bridge won't be able to sync the member
|
||||||
# list regardless of this setting.
|
# list regardless of this setting.
|
||||||
sync_channel_members: true
|
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
|
# Whether or not to automatically synchronize contacts and chats of Matrix users logged into
|
||||||
# their Telegram account at startup.
|
# their Telegram account at startup.
|
||||||
startup_sync: true
|
startup_sync: true
|
||||||
|
|||||||
@@ -202,6 +202,7 @@ class Config(DictWithRecursion):
|
|||||||
copy("bridge.bot_messages_as_notices")
|
copy("bridge.bot_messages_as_notices")
|
||||||
copy("bridge.max_initial_member_sync")
|
copy("bridge.max_initial_member_sync")
|
||||||
copy("bridge.sync_channel_members")
|
copy("bridge.sync_channel_members")
|
||||||
|
copy("bridge.skip_deleted_members")
|
||||||
copy("bridge.startup_sync")
|
copy("bridge.startup_sync")
|
||||||
copy("bridge.sync_dialog_limit")
|
copy("bridge.sync_dialog_limit")
|
||||||
copy("bridge.sync_matrix_state")
|
copy("bridge.sync_matrix_state")
|
||||||
|
|||||||
@@ -461,13 +461,16 @@ class Portal:
|
|||||||
self.bot.add_chat(self.tgid, self.peer_type)
|
self.bot.add_chat(self.tgid, self.peer_type)
|
||||||
return
|
return
|
||||||
|
|
||||||
user = u.User.get_by_tgid(bot.id)
|
user = u.User.get_by_tgid(TelegramID(bot.id))
|
||||||
if user and user.is_bot:
|
if user and user.is_bot:
|
||||||
user.register_portal(self)
|
user.register_portal(self)
|
||||||
|
|
||||||
async def sync_telegram_users(self, source: 'AbstractUser', users: List[User]) -> None:
|
async def sync_telegram_users(self, source: 'AbstractUser', users: List[User]) -> None:
|
||||||
allowed_tgids = set()
|
allowed_tgids = set()
|
||||||
|
skip_deleted = config["bridge.skip_deleted_members"]
|
||||||
for entity in users:
|
for entity in users:
|
||||||
|
if skip_deleted and entity.deleted:
|
||||||
|
continue
|
||||||
puppet = p.Puppet.get(TelegramID(entity.id))
|
puppet = p.Puppet.get(TelegramID(entity.id))
|
||||||
if entity.bot:
|
if entity.bot:
|
||||||
self.add_bot_chat(entity)
|
self.add_bot_chat(entity)
|
||||||
@@ -475,7 +478,7 @@ class Portal:
|
|||||||
await puppet.intent.ensure_joined(self.mxid)
|
await puppet.intent.ensure_joined(self.mxid)
|
||||||
await puppet.update_info(source, entity)
|
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:
|
if user:
|
||||||
await self.invite_to_matrix(user.mxid)
|
await self.invite_to_matrix(user.mxid)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user