From 01426308c5fc29c8f5fa11e4dce6d971b5fe12af Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 7 Jan 2019 19:58:16 +0200 Subject: [PATCH] Make automatic full Matrix state syncs optional --- example-config.yaml | 3 +++ mautrix_telegram/config.py | 1 + mautrix_telegram/portal.py | 6 ++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/example-config.yaml b/example-config.yaml index e291c5ea..a91ee949 100644 --- a/example-config.yaml +++ b/example-config.yaml @@ -107,6 +107,9 @@ 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 automatically sync the Matrix room state (mostly unpuppeted displaynames) + # at startup and when creating a bridge. + sync_matrix_state: true # The maximum number of simultaneous Telegram deletions to handle. # A large number of simultaneous redactions could put strain on your homeserver. max_telegram_delete: 10 diff --git a/mautrix_telegram/config.py b/mautrix_telegram/config.py index 98d6c7f9..c5206121 100644 --- a/mautrix_telegram/config.py +++ b/mautrix_telegram/config.py @@ -203,6 +203,7 @@ class Config(DictWithRecursion): copy("bridge.bot_messages_as_notices") copy("bridge.max_initial_member_sync") copy("bridge.sync_channel_members") + copy("bridge.sync_matrix_state") copy("bridge.max_telegram_delete") copy("bridge.allow_matrix_login") copy("bridge.inline_images") diff --git a/mautrix_telegram/portal.py b/mautrix_telegram/portal.py index ef216aaa..83fb6137 100644 --- a/mautrix_telegram/portal.py +++ b/mautrix_telegram/portal.py @@ -101,6 +101,7 @@ class Portal: public_portals = False # type: bool max_initial_member_sync = -1 # type: int sync_channel_members = True # type: bool + sync_matrix_state = True # type: bool dedup_pre_db_check = False # type: bool dedup_cache_queue_length = 20 # type: int @@ -328,7 +329,8 @@ class Portal: puppet = p.Puppet.get(self.tgid) await puppet.update_info(user, entity) await puppet.intent.join_room(self.mxid) - await self.sync_matrix_members() + if self.sync_matrix_state: + await self.sync_matrix_members() async def create_matrix_room(self, user: 'AbstractUser', entity: TypeChat = None, invites: InviteList = None, update_if_exists: bool = True, @@ -786,7 +788,6 @@ class Portal: async def sync_matrix_members(self) -> None: resp = await self.main_intent.get_room_joined_memberships(self.mxid) members = resp["joined"] - print(members) for mxid, info in members.items(): member = { "membership": "join", @@ -1955,6 +1956,7 @@ def init(context: Context) -> None: Portal.az, Portal.db, config, Portal.loop, Portal.bot = context.core Portal.max_initial_member_sync = config["bridge.max_initial_member_sync"] Portal.sync_channel_members = config["bridge.sync_channel_members"] + Portal.sync_matrix_state = config["bridge.sync_matrix_state"] Portal.public_portals = config["bridge.public_portals"] Portal.filter_mode = config["bridge.filter.mode"] Portal.filter_list = config["bridge.filter.list"]