summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/handlers.py7
-rw-r--r--src/tabs/basetabs.py4
-rw-r--r--src/text_buffer.py9
3 files changed, 15 insertions, 5 deletions
diff --git a/src/core/handlers.py b/src/core/handlers.py
index 6c29e7c2..03a6d32d 100644
--- a/src/core/handlers.py
+++ b/src/core/handlers.py
@@ -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):
"""
diff --git a/src/tabs/basetabs.py b/src/tabs/basetabs.py
index c238bbd4..730d702b 100644
--- a/src/tabs/basetabs.py
+++ b/src/tabs/basetabs.py
@@ -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()
diff --git a/src/text_buffer.py b/src/text_buffer.py
index 59aa96e1..db68c11f 100644
--- a/src/text_buffer.py
+++ b/src/text_buffer.py
@@ -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)