From 85b8f5def7a3f40504b8f814437bf7e4507fc3ba Mon Sep 17 00:00:00 2001 From: Malte E Date: Sun, 21 Aug 2022 17:49:18 +0200 Subject: [PATCH] Don't check whether User is channel, add peer property to User --- mautrix_telegram/portal.py | 2 +- mautrix_telegram/user.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/mautrix_telegram/portal.py b/mautrix_telegram/portal.py index 076e2908..84a77ae9 100644 --- a/mautrix_telegram/portal.py +++ b/mautrix_telegram/portal.py @@ -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": diff --git a/mautrix_telegram/user.py b/mautrix_telegram/user.py index 4641523d..47fc191c 100644 --- a/mautrix_telegram/user.py +++ b/mautrix_telegram/user.py @@ -31,6 +31,7 @@ ChatForbidden, InputUserSelf, NotifyPeer, + PeerUser, TypeUpdate, UpdateFolderPeers, UpdateNewChannelMessage, @@ -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: