Fix private tabs

- receipts
- receiving messages
- showing our sent messages
This commit is contained in:
mathieui 2019-08-25 23:00:49 +02:00
parent a157a21c87
commit 45d12b9092
No known key found for this signature in database
GPG key ID: C59F84CEEFD616E3
2 changed files with 8 additions and 7 deletions

View file

@ -801,7 +801,7 @@ class HandlerCore:
jid=message['from'], jid=message['from'],
typ=1) typ=1)
if sent: if sent:
tab.last_sent_message = msg tab.last_sent_message = message
else: else:
tab.last_remote_message = datetime.now() tab.last_remote_message = datetime.now()

View file

@ -86,9 +86,9 @@ class PrivateTab(OneToOneTab):
return self.get_nick() return self.get_nick()
def ack_message(self, msg_id: str, msg_jid: JID): def ack_message(self, msg_id: str, msg_jid: JID):
# special case when talking to oneself if JID(msg_jid).bare == self.core.xmpp.boundjid.bare:
if msg_jid == self.core.xmpp.boundjid: msg_jid = JID(self.jid.bare)
msg_jid = self.jid.full msg_jid.resource = self.own_nick
super().ack_message(msg_id, msg_jid) super().ack_message(msg_id, msg_jid)
@staticmethod @staticmethod
@ -149,10 +149,11 @@ class PrivateTab(OneToOneTab):
def command_say(self, line, attention=False, correct=False): def command_say(self, line, attention=False, correct=False):
if not self.on: if not self.on:
return return
echo_message = self.jid.resource != self.own_nick our_jid = JID(self.jid.bare)
our_jid.resource = self.own_nick
msg = self.core.xmpp.make_message( msg = self.core.xmpp.make_message(
mto=self.jid.full, mto=self.jid.full,
mfrom=self.core.xmpp.boundjid mfrom=our_jid,
) )
msg['type'] = 'chat' msg['type'] = 'chat'
msg['body'] = line msg['body'] = line
@ -182,7 +183,7 @@ class PrivateTab(OneToOneTab):
if not msg['body']: if not msg['body']:
return return
self.last_sent_message = msg self.last_sent_message = msg
self.core.handler.on_normal_message(msg) self.core.handler.on_groupchat_private_message(msg, sent=True)
msg._add_receipt = True msg._add_receipt = True
msg.send() msg.send()
self.cancel_paused_delay() self.cancel_paused_delay()