From 58f8ee2ee2f5da1843a088ae92b40edfc75cae27 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Wed, 30 Mar 2022 11:58:40 +0300 Subject: [PATCH] Add config option to mark joined Telegram notices as read automatically --- mautrix_telegram/config.py | 1 + mautrix_telegram/example-config.yaml | 2 ++ mautrix_telegram/portal.py | 5 +---- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mautrix_telegram/config.py b/mautrix_telegram/config.py index 2fdf9c7c..2888365d 100644 --- a/mautrix_telegram/config.py +++ b/mautrix_telegram/config.py @@ -159,6 +159,7 @@ class Config(BaseBridgeConfig): copy("bridge.tag_only_on_create") copy("bridge.bridge_matrix_leave") copy("bridge.kick_on_logout") + copy("bridge.always_read_joined_telegram_notice") copy("bridge.backfill.invite_own_puppet") copy("bridge.backfill.takeout_limit") copy("bridge.backfill.initial_limit") diff --git a/mautrix_telegram/example-config.yaml b/mautrix_telegram/example-config.yaml index e1f70a79..d5439ac1 100644 --- a/mautrix_telegram/example-config.yaml +++ b/mautrix_telegram/example-config.yaml @@ -282,6 +282,8 @@ bridge: bridge_matrix_leave: true # Should the user be kicked out of all portals when logging out of the bridge? kick_on_logout: true + # Should the "* user joined Telegram" notice always be marked as read automatically? + always_read_joined_telegram_notice: true # Settings for backfilling messages from Telegram. backfill: # Whether or not the Telegram ghosts of logged in Matrix users should be diff --git a/mautrix_telegram/portal.py b/mautrix_telegram/portal.py index ddae8f85..f185c10f 100644 --- a/mautrix_telegram/portal.py +++ b/mautrix_telegram/portal.py @@ -3339,10 +3339,7 @@ class Portal(DBPortal, BasePortal): tg_space=source.tgid, edit_index=0, ).insert() - # Automatically mark the notice as read if we're backfilling messages, mostly so that - # empty rooms created before the notice was added wouldn't become unread when the notice - # is backfilled in. - if backfill: + if self.config["bridge.always_read_joined_telegram_notice"]: double_puppet = await p.Puppet.get_by_tgid(source.tgid) if double_puppet and double_puppet.is_real_user: await double_puppet.intent.mark_read(self.mxid, event_id)