Move config check when handling ghost invites

This commit is contained in:
Tulir Asokan
2022-07-17 16:09:02 +03:00
parent 70b73868c7
commit b6312f306a
+5 -9
View File
@@ -71,13 +71,12 @@ class MatrixHandler(BaseMatrixHandler):
evt: StateEvent,
members: list[UserID],
) -> None:
if not invited_by.is_logged_in:
await puppet.default_mxid_intent.leave_room(
room_id, reason="You are not logged into this Telegram bridge"
)
return
double_puppet = await pu.Puppet.get_by_custom_mxid(invited_by.mxid)
if not double_puppet or self.az.bot_mxid in members:
if (
not double_puppet
or self.az.bot_mxid in members
or not not self.config["bridge.create_group_on_invite"]
):
if self.az.bot_mxid not in members:
await puppet.default_mxid_intent.leave_room(
room_id,
@@ -89,7 +88,6 @@ class MatrixHandler(BaseMatrixHandler):
"This ghost will remain inactive until a Telegram chat is created for this room.",
)
return
elif not await user_has_power_level(
evt.room_id, double_puppet.intent, invited_by, "bridge"
):
@@ -97,8 +95,6 @@ class MatrixHandler(BaseMatrixHandler):
room_id, reason="You do not have the permissions to bridge this room."
)
return
elif not self.config["bridge.create_group_on_invite"]:
return
await double_puppet.intent.invite_user(room_id, self.az.bot_mxid)