From 131686626537645737cf9e9afbdb58ddaa97d54b Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Sat, 20 Feb 2016 20:04:47 +0100 Subject: [PATCH] reply to message receipt only when we are the recipient of the message. see #7548. [tmolitor] display message receipt (xep 0184) for carbon copied messages. Fixes #8258 --- src/common/connection_handlers.py | 12 ++++++++++-- src/common/connection_handlers_events.py | 3 +++ src/roster_window.py | 5 ++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index bbf7dfd32..a4035f4c6 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -1169,12 +1169,20 @@ class ConnectionHandlersBase: contact = gajim.contacts.get_contact(self.name, obj.jid) nick = obj.resource gc_contact = gajim.contacts.get_gc_contact(self.name, obj.jid, nick) + jid_to = obj.stanza.getTo() + reply = False + if not jid_to: + reply = True + else: + fjid_to = helpers.parse_jid(str(jid_to)) + jid_to = gajim.get_jid_without_resource(fjid_to) + if jid_to == gajim.get_jid_from_account(self.name): + reply = True if obj.receipt_request_tag and gajim.config.get_per('accounts', self.name, 'answer_receipts') and ((contact and contact.sub \ not in ('to', 'none')) or gc_contact) and obj.mtype != 'error' and \ - not obj.forwarded: + reply: receipt = nbxmpp.Message(to=obj.fjid, typ='chat') - receipt.setID(obj.id_) receipt.setTag('received', namespace='urn:xmpp:receipts', attrs={'id': obj.id_}) diff --git a/src/common/connection_handlers_events.py b/src/common/connection_handlers_events.py index c6eded8dc..20e28e0be 100644 --- a/src/common/connection_handlers_events.py +++ b/src/common/connection_handlers_events.py @@ -2349,6 +2349,9 @@ class NotificationEvent(nec.NetworkIncomingEvent): self.control_focused = True def handle_incoming_msg_event(self, msg_obj): + # don't alert for carbon copied messages from ourselves + if msg_obj.sent: + return if not msg_obj.msgtxt: return self.jid = msg_obj.jid diff --git a/src/roster_window.py b/src/roster_window.py index 5d9bba598..d00d4c1ff 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -2756,15 +2756,18 @@ class RosterWindow: return if obj.session.control and obj.mtype == 'chat': typ = '' + xep0184_id = None if obj.mtype == 'error': typ = 'error' if obj.forwarded and obj.sent: typ = 'out' + xep0184_id = obj.id_ obj.session.control.print_conversation(obj.msgtxt, typ, tim=obj.timestamp, encrypted=obj.encrypted, subject=obj.subject, xhtml=obj.xhtml, displaymarking=obj.displaymarking, - msg_id=obj.msg_id, correct_id=(obj.id_, obj.correct_id)) + msg_id=obj.msg_id, correct_id=(obj.id_, obj.correct_id), + xep0184_id=xep0184_id) if obj.msg_id: pw = obj.session.control.parent_win end = obj.session.control.was_at_the_end