diff --git a/mautrix_telegram/db/message.py b/mautrix_telegram/db/message.py index 06608328..d6b228a3 100644 --- a/mautrix_telegram/db/message.py +++ b/mautrix_telegram/db/message.py @@ -42,10 +42,11 @@ class Message(Base): def get_one_by_tgid(cls, tgid: TelegramID, tg_space: TelegramID, edit_index: int = 0 ) -> Optional['Message']: if edit_index < 0: - return cls._one_or_none(cls.t.select() - .where(and_(cls.c.tgid == tgid, cls.c.tg_space == tg_space)) - .order_by(desc(cls.c.edit_index)) - .limit(1).offset(-edit_index - 1)) + return cls._one_or_none(cls.db.execute( + cls.t.select() + .where(and_(cls.c.tgid == tgid, cls.c.tg_space == tg_space)) + .order_by(desc(cls.c.edit_index)) + .limit(1).offset(-edit_index - 1))) else: return cls._select_one_or_none(cls.c.tgid == tgid, cls.c.tg_space == tg_space, cls.c.edit_index == edit_index) diff --git a/mautrix_telegram/portal/telegram.py b/mautrix_telegram/portal/telegram.py index c6617acb..6ccf62cd 100644 --- a/mautrix_telegram/portal/telegram.py +++ b/mautrix_telegram/portal/telegram.py @@ -351,17 +351,6 @@ class PortalTelegram(BasePortal, ABC): content.external_url = self._get_external_url(evt) content.set_edit(editing_msg.mxid) - # TODO remove this stuff once mautrix-python generates m.new_content - new_content = content.serialize() - new_content["net.maunium.telegram.puppet"] = True - del new_content["m.relates_to"] - content["m.new_content"] = new_content - content.body = f"Edit: {content.body}" - content.format = Format.HTML - content.formatted_body = (f"Edit: " - f"{content.formatted_body or escape_html(content.body)}") - intent = sender.intent_for(self) if sender else self.main_intent await intent.set_typing(self.mxid, is_typing=False) event_id = await intent.send_message(self.mxid, content)