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.
This commit is contained in:
Philipp Hörist 2017-03-21 19:33:41 +01:00
parent 33a584b8b0
commit d346333d2a
1 changed files with 20 additions and 0 deletions

View File

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