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
This commit is contained in:
Yann Leboulanger 2016-02-20 20:04:47 +01:00
parent 580cdb2723
commit 1316866265
3 changed files with 17 additions and 3 deletions

View File

@ -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_})

View File

@ -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

View File

@ -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