Only graphically ack a message if it was sent by us
This commit is contained in:
parent
1debbe6a72
commit
25d2bcbbff
3 changed files with 15 additions and 5 deletions
|
@ -33,7 +33,7 @@ from config import config, CACHE_DIR
|
|||
from contact import Resource
|
||||
from logger import logger
|
||||
from roster import roster
|
||||
from text_buffer import CorrectionError
|
||||
from text_buffer import CorrectionError, AckError
|
||||
from theming import dump_tuple, get_theme
|
||||
|
||||
from . commands import dumb_callback
|
||||
|
@ -1065,7 +1065,10 @@ def on_receipt(self, message):
|
|||
if not conversation:
|
||||
return
|
||||
|
||||
conversation.ack_message(msg_id)
|
||||
try:
|
||||
conversation.ack_message(msg_id, self.xmpp.boundjid)
|
||||
except AckError:
|
||||
log.debug('Error while receiving an ack', exc_info=True)
|
||||
|
||||
def on_data_form(self, message):
|
||||
"""
|
||||
|
|
|
@ -737,11 +737,11 @@ class OneToOneTab(ChatTab):
|
|||
self.add_message(msg, typ=0)
|
||||
self.core.refresh_window()
|
||||
|
||||
def ack_message(self, msg_id):
|
||||
def ack_message(self, msg_id, msg_jid):
|
||||
"""
|
||||
Ack a message
|
||||
"""
|
||||
new_msg = self._text_buffer.ack_message(msg_id)
|
||||
new_msg = self._text_buffer.ack_message(msg_id, msg_jid)
|
||||
if new_msg:
|
||||
self.text_win.modify_message(msg_id, new_msg)
|
||||
self.core.refresh_window()
|
||||
|
|
|
@ -24,6 +24,9 @@ Message = collections.namedtuple('Message', message_fields)
|
|||
class CorrectionError(Exception):
|
||||
pass
|
||||
|
||||
class AckError(Exception):
|
||||
pass
|
||||
|
||||
def other_elems(self):
|
||||
"Helper for the repr_message function"
|
||||
acc = ['Message(']
|
||||
|
@ -161,7 +164,7 @@ class TextBuffer(object):
|
|||
return i
|
||||
return -1
|
||||
|
||||
def ack_message(self, old_id):
|
||||
def ack_message(self, old_id, jid):
|
||||
"""
|
||||
Ack a message
|
||||
"""
|
||||
|
@ -169,6 +172,10 @@ class TextBuffer(object):
|
|||
if i == -1:
|
||||
return
|
||||
msg = self.messages[i]
|
||||
if msg.jid != jid:
|
||||
raise AckError('Wrong JID for message id %s (was %s, expected %s)' %
|
||||
(old_id, msg.jid, jid))
|
||||
|
||||
new_msg = list(msg)
|
||||
new_msg[12] = True
|
||||
new_msg = Message(*new_msg)
|
||||
|
|
Loading…
Reference in a new issue