Skip to content

Commit

Permalink
Don't check whether User is channel, add peer property to User
Browse files Browse the repository at this point in the history
  • Loading branch information
maltee1 authored and tulir committed Aug 24, 2022
1 parent f012cb7 commit 85b8f5d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mautrix_telegram/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ async def create_telegram_chat(
async def handle_matrix_invite(
self, invited_by: u.User, puppet: p.Puppet | au.AbstractUser
) -> None:
if puppet.is_channel:
if isinstance(puppet, p.Puppet) and puppet.is_channel:
raise ValueError("Can't invite channels to chats")
try:
if self.peer_type == "chat":
Expand Down
5 changes: 5 additions & 0 deletions mautrix_telegram/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
ChatForbidden,
InputUserSelf,
NotifyPeer,
PeerUser,
TypeUpdate,
UpdateFolderPeers,
UpdateNewChannelMessage,
Expand Down Expand Up @@ -130,6 +131,10 @@ def mxid_localpart(self) -> str:
def human_tg_id(self) -> str:
return f"@{self.tg_username}" if self.tg_username else f"+{self.tg_phone}" or None

@property
def peer(self) -> PeerUser | None:
return PeerUser(user_id=self.tgid) if self.tgid else None

# TODO replace with proper displayname getting everywhere
@property
def displayname(self) -> str:
Expand Down

0 comments on commit 85b8f5d

Please sign in to comment.