From 8a25762e7be52022cd377a563efb5be1534532b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Sun, 5 Apr 2020 02:58:02 +0200 Subject: [PATCH] /correct: send new-style LMC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- poezio/core/handlers.py | 4 ++-- poezio/tabs/basetabs.py | 9 +++++++++ poezio/tabs/conversationtab.py | 2 +- poezio/tabs/muctab.py | 2 +- poezio/tabs/privatetab.py | 2 +- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/poezio/core/handlers.py b/poezio/core/handlers.py index 9089cd0c..94b4da5c 100644 --- a/poezio/core/handlers.py +++ b/poezio/core/handlers.py @@ -770,7 +770,7 @@ class HandlerCore: self.core.events.trigger('highlight', message, tab) if message['from'].resource == tab.own_nick: - tab.last_sent_message = message + tab.set_last_sent_message(message, correct=replaced) if tab is self.core.tabs.current_tab: tab.text_win.refresh() @@ -862,7 +862,7 @@ class HandlerCore: jid=message['from'], typ=1) if sent: - tab.last_sent_message = message + tab.set_last_sent_message(message, correct=replaced) else: tab.last_remote_message = datetime.now() diff --git a/poezio/tabs/basetabs.py b/poezio/tabs/basetabs.py index c5d074bd..706172ed 100644 --- a/poezio/tabs/basetabs.py +++ b/poezio/tabs/basetabs.py @@ -748,6 +748,15 @@ class ChatTab(Tab): self.core.remove_timed_event(self.timed_event_not_paused) self.timed_event_not_paused = None + def set_last_sent_message(self, msg, correct=False): + """Ensure last_sent_message is set with the correct attributes""" + if correct: + # XXX: Is the copy needed. Is the object passed here reused + # afterwards? Who knows. + msg = copy.copy(msg) + msg['id'] = self.last_sent_message['id'] + self.last_sent_message = msg + @command_args_parser.raw def command_correct(self, line): """ diff --git a/poezio/tabs/conversationtab.py b/poezio/tabs/conversationtab.py index 39411872..410c5eda 100644 --- a/poezio/tabs/conversationtab.py +++ b/poezio/tabs/conversationtab.py @@ -139,7 +139,7 @@ class ConversationTab(OneToOneTab): self.core.events.trigger('conversation_say_after', msg, self) if not msg['body']: return - self.last_sent_message = msg + self.set_last_sent_message(msg, correct=correct) self.core.handler.on_normal_message(msg) msg._add_receipt = True msg.send() diff --git a/poezio/tabs/muctab.py b/poezio/tabs/muctab.py index 73aa1457..540911cb 100644 --- a/poezio/tabs/muctab.py +++ b/poezio/tabs/muctab.py @@ -1681,7 +1681,7 @@ class MucTab(ChatTab): self.text_win.refresh() self.input.refresh() return - self.last_sent_message = msg + self.set_last_sent_message(msg, correct=correct) msg.send() self.chat_state = needed diff --git a/poezio/tabs/privatetab.py b/poezio/tabs/privatetab.py index 8d2c1b11..ee4cd84c 100644 --- a/poezio/tabs/privatetab.py +++ b/poezio/tabs/privatetab.py @@ -177,7 +177,7 @@ class PrivateTab(OneToOneTab): self.core.events.trigger('private_say_after', msg, self) if not msg['body']: return - self.last_sent_message = msg + self.set_last_sent_message(msg, correct=correct) self.core.handler.on_groupchat_private_message(msg, sent=True) msg._add_receipt = True msg.send()