/correct: send new-style LMC

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2020-04-05 02:58:02 +02:00
parent 747deb41e6
commit 8a25762e7b
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2
5 changed files with 14 additions and 5 deletions

View file

@ -770,7 +770,7 @@ class HandlerCore:
self.core.events.trigger('highlight', message, tab) self.core.events.trigger('highlight', message, tab)
if message['from'].resource == tab.own_nick: 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: if tab is self.core.tabs.current_tab:
tab.text_win.refresh() tab.text_win.refresh()
@ -862,7 +862,7 @@ class HandlerCore:
jid=message['from'], jid=message['from'],
typ=1) typ=1)
if sent: if sent:
tab.last_sent_message = message tab.set_last_sent_message(message, correct=replaced)
else: else:
tab.last_remote_message = datetime.now() tab.last_remote_message = datetime.now()

View file

@ -748,6 +748,15 @@ class ChatTab(Tab):
self.core.remove_timed_event(self.timed_event_not_paused) self.core.remove_timed_event(self.timed_event_not_paused)
self.timed_event_not_paused = None 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 @command_args_parser.raw
def command_correct(self, line): def command_correct(self, line):
""" """

View file

@ -139,7 +139,7 @@ class ConversationTab(OneToOneTab):
self.core.events.trigger('conversation_say_after', msg, self) self.core.events.trigger('conversation_say_after', msg, self)
if not msg['body']: if not msg['body']:
return return
self.last_sent_message = msg self.set_last_sent_message(msg, correct=correct)
self.core.handler.on_normal_message(msg) self.core.handler.on_normal_message(msg)
msg._add_receipt = True msg._add_receipt = True
msg.send() msg.send()

View file

@ -1681,7 +1681,7 @@ class MucTab(ChatTab):
self.text_win.refresh() self.text_win.refresh()
self.input.refresh() self.input.refresh()
return return
self.last_sent_message = msg self.set_last_sent_message(msg, correct=correct)
msg.send() msg.send()
self.chat_state = needed self.chat_state = needed

View file

@ -177,7 +177,7 @@ class PrivateTab(OneToOneTab):
self.core.events.trigger('private_say_after', msg, self) self.core.events.trigger('private_say_after', msg, self)
if not msg['body']: if not msg['body']:
return return
self.last_sent_message = msg self.set_last_sent_message(msg, correct=correct)
self.core.handler.on_groupchat_private_message(msg, sent=True) self.core.handler.on_groupchat_private_message(msg, sent=True)
msg._add_receipt = True msg._add_receipt = True
msg.send() msg.send()