From c31e0a50b57b1cb4fa7a19de7a34124f351cfa86 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 14 Feb 2019 00:57:27 +0200 Subject: [PATCH] Add option to disable startup sync. Fixes #176 --- example-config.yaml | 3 +++ mautrix_telegram/config.py | 1 + mautrix_telegram/user.py | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/example-config.yaml b/example-config.yaml index 9f899bbd..02a626af 100644 --- a/example-config.yaml +++ b/example-config.yaml @@ -104,6 +104,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 synchronize contacts and chats of Matrix users logged into + # their Telegram account at startup. + startup_sync: 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 468522f5..f21ca536 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.startup_sync") copy("bridge.sync_matrix_state") copy("bridge.max_telegram_delete") copy("bridge.allow_matrix_login") diff --git a/mautrix_telegram/user.py b/mautrix_telegram/user.py index 69642468..2f51675c 100644 --- a/mautrix_telegram/user.py +++ b/mautrix_telegram/user.py @@ -171,7 +171,7 @@ class User(AbstractUser): async def post_login(self, info: TLUser = None) -> None: try: await self.update_info(info) - if not self.is_bot: + if not self.is_bot and config["bridge.startup_sync"]: await self.sync_dialogs() await self.sync_contacts() if config["bridge.catch_up"]: @@ -363,7 +363,7 @@ class User(AbstractUser): return None @classmethod - def get_by_tgid(cls, tgid: int) -> Optional['User']: + def get_by_tgid(cls, tgid: TelegramID) -> Optional['User']: try: return cls.by_tgid[tgid] except KeyError: