Fix potential issues with ignore_unbridged_group_chat option

This commit is contained in:
Tulir Asokan
2023-12-15 22:27:39 +02:00
parent 3609eb2b70
commit 87909d07ec
3 changed files with 16 additions and 2 deletions

View File

@@ -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.

View File

@@ -658,7 +658,11 @@ class AbstractUser(ABC):
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)

View File

@@ -787,6 +787,8 @@ class Portal(DBPortal, BasePortal):
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(
@@ -3372,6 +3374,8 @@ class Portal(DBPortal, BasePortal):
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:
@@ -3536,7 +3540,7 @@ class Portal(DBPortal, BasePortal):
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 = (