From d346333d2ac1851fbd0d94fd106b45c9539356f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Tue, 21 Mar 2017 19:33:41 +0100 Subject: [PATCH] Drop some message from ourself - 'received'-Carbons from ourself, because we either received the message directly or got a 'sent'-Carbon about it - Messages from our own full jid, this can happen when we send a Message to ourself and no other resource is online. --- src/common/connection_handlers_events.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/common/connection_handlers_events.py b/src/common/connection_handlers_events.py index 0263820fb..286f935fb 100644 --- a/src/common/connection_handlers_events.py +++ b/src/common/connection_handlers_events.py @@ -1124,6 +1124,15 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): self.sent = False account = self.conn.name + our_full_jid = gajim.get_jid_from_account(account, full=True) + if self.stanza.getFrom() == our_full_jid: + # Drop messages sent from our own full jid + # It can happen that when we sent message to our own bare jid + # that the server routes that message back to us + log.info('Received message from self: %s, message is dropped' + % self.stanza.getFrom()) + return + # check if the message is a roster item exchange (XEP-0144) if self.stanza.getTag('x', namespace=nbxmpp.NS_ROSTERX): gajim.nec.push_incoming_event(RosterItemExchangeEvent(None, @@ -1179,6 +1188,17 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): to = gajim.get_jid_from_account(account) self.stanza.setFrom(to) self.sent = True + elif carbon_marker.getName() == 'received': + full_frm = str(self.stanza.getFrom()) + frm = gajim.get_jid_without_resource(full_frm) + if frm == gajim.get_jid_from_account(account): + # Drop 'received' Carbons from ourself, we already + # got the message with the 'sent' Carbon or via the + # message itself + log.info( + 'Drop "received"-Carbon from ourself: %s' + % full_frm) + return try: self.get_jid_resource() except helpers.InvalidFormat: