Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions mautrix_telegram/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
from telethon.tl.custom import Dialog
from telethon.tl.functions.channels import (
CreateChannelRequest,
EditAdminRequest,
EditPhotoRequest,
EditTitleRequest,
InviteToChannelRequest,
Expand Down Expand Up @@ -93,6 +94,7 @@
Channel,
ChannelFull,
Chat,
ChatAdminRights,
ChatBannedRights,
ChatEmpty,
ChatFull,
Expand Down Expand Up @@ -680,9 +682,14 @@ async def handle_matrix_invite(
AddChatUserRequest(chat_id=self.tgid, user_id=puppet.tgid, fwd_limit=0)
)
elif self.peer_type == "channel":
await invited_by.client(
InviteToChannelRequest(channel=self.peer, users=[puppet.tgid])
)
if not puppet.is_bot:
await invited_by.client(
InviteToChannelRequest(channel=self.peer, users=[puppet.tgid])
)
else:
await invited_by.client(
EditAdminRequest(channel=self.peer, user_id=puppet.tgid, admin_rights=ChatAdminRights(), rank="Bridge")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Users can invite anything, not only relaybots, so the admin title shouldn't be hardcoded

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can they invite bots? cause this condition is for bots in channels only which can only be admins who manage channel on behalf of users in the bridged matrix room
I'm open to suggestions on what to rename this rank to, because I think it's required unless you suggest just passing empty string to rank argument. Perhaps "Relay" or "Matrix bot"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The relay bot has no special status, it's just a random telegram bot that the user is inviting. Users can invite any other bot or user the exact same way

)
# We don't care if there are invites for private chat portals with the relaybot.
elif not self.bot or self.tg_receiver != self.bot.tgid:
raise RejectMatrixInvite("You can't invite additional users to private chats.")
Expand Down
Loading