Skip to content

Commit

Permalink
Fix potential issues with ignore_unbridged_group_chat option
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Dec 15, 2023
1 parent 3609eb2 commit 87909d0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v0.15.1 (unreleased)

* Updated Docker image to Alpine 3.19.
* Fixed some potential cases where a portal room would be created for the
relaybot even if `ignore_unbridged_group_chat` was enabled.

# v0.15.0 (2023-11-26)

* Removed support for MSC2716 backfilling.
Expand Down
6 changes: 5 additions & 1 deletion mautrix_telegram/abstract_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,11 @@ async def update_channel(self, update: UpdateChannel) -> None:
await portal.delete_telegram_user(self.tgid, sender=None)
elif chan := getattr(update, "mau_channel", None):
if not portal.mxid:
background_task.create(self._delayed_create_channel(chan))
if (
not self.is_relaybot
or not self.config["bridge.relaybot.ignore_unbridged_group_chat"]
):
background_task.create(self._delayed_create_channel(chan))
else:
self.log.debug("Updating channel info with data fetched by Telethon")
await portal.update_info(self, chan)
Expand Down
6 changes: 5 additions & 1 deletion mautrix_telegram/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,8 @@ async def create_matrix_room(
background_task.create(update)
await self.invite_to_matrix(invites or [])
return self.mxid
elif user.is_relaybot and self.config["bridge.relaybot.ignore_unbridged_group_chat"]:
raise Exception("create_matrix_room called as relaybot")
async with self._room_create_lock:
try:
return await self._create_matrix_room(
Expand Down Expand Up @@ -3372,6 +3374,8 @@ async def _handle_telegram_message(
self, source: au.AbstractUser, sender: p.Puppet | None, evt: Message
) -> None:
if not self.mxid:
if source.is_relaybot and self.config["bridge.relaybot.ignore_unbridged_group_chat"]:
return
self.log.debug("Got telegram message %d, but no room exists, creating...", evt.id)
await self.create_matrix_room(source, invites=[source.mxid], update_if_exists=False)
if not self.mxid:
Expand Down Expand Up @@ -3536,7 +3540,7 @@ async def _mark_disappearing(
async def _create_room_on_action(
self, source: au.AbstractUser, action: TypeMessageAction
) -> bool:
if source.is_relaybot and self.config["bridge.ignore_unbridged_group_chat"]:
if source.is_relaybot and self.config["bridge.relaybot.ignore_unbridged_group_chat"]:
return False
create_and_exit = (MessageActionChatCreate, MessageActionChannelCreate)
create_and_continue = (
Expand Down

0 comments on commit 87909d0

Please sign in to comment.