diff --git a/example-config.yaml b/example-config.yaml index e3aaa16b..627f923d 100644 --- a/example-config.yaml +++ b/example-config.yaml @@ -98,6 +98,8 @@ bridge: # Only enable this if your displayname_template has some static part that the bridge can use to # reliably identify what is a plaintext highlight. plaintext_highlights: false + # Whether or not to make portals of publicly joinable channels/supergroups publicly joinable on Matrix. + public_portals: true # The prefix for commands. Only required in non-management rooms. command_prefix: "!tg" diff --git a/mautrix_telegram/config.py b/mautrix_telegram/config.py index cd645e24..55b4ad46 100644 --- a/mautrix_telegram/config.py +++ b/mautrix_telegram/config.py @@ -175,6 +175,7 @@ class Config(DictWithRecursion): copy("bridge.allow_matrix_login") copy("bridge.inline_images") copy("bridge.plaintext_highlights") + copy("bridge.public_portals") copy("bridge.command_prefix") diff --git a/mautrix_telegram/portal.py b/mautrix_telegram/portal.py index 8a64207c..dc83f7f4 100644 --- a/mautrix_telegram/portal.py +++ b/mautrix_telegram/portal.py @@ -244,7 +244,7 @@ class Portal: self._main_intent = puppet.intent if direct else self.az.intent if self.peer_type == "channel" and entity.username: - public = True + public = config["bridge.public_portals"] alias = self._get_alias_localpart(entity.username) self.username = entity.username else: @@ -403,7 +403,8 @@ class Portal: self.username = username or None if self.username: await self.main_intent.add_room_alias(self.mxid, self._get_alias_localpart()) - await self.main_intent.set_join_rule(self.mxid, "public") + if config["bridge.public_portals"]: + await self.main_intent.set_join_rule(self.mxid, "public") else: await self.main_intent.set_join_rule(self.mxid, "invite")