comparison sat/plugins/plugin_sec_otr.py @ 2821:3d735e0ab2fa

plugin OTR: ignore messages from sender without resource or from own jid
author Goffi <goffi@goffi.org>
date Fri, 01 Mar 2019 12:13:55 +0100
parents 7ab8684784c6
children ab2696e34d29
comparison
equal deleted inserted replaced
2820:7ab8684784c6 2821:3d735e0ab2fa
731 731
732 def MessageReceivedTrigger(self, client, message_elt, post_treat): 732 def MessageReceivedTrigger(self, client, message_elt, post_treat):
733 if message_elt.getAttribute("type") == C.MESS_TYPE_GROUPCHAT: 733 if message_elt.getAttribute("type") == C.MESS_TYPE_GROUPCHAT:
734 # OTR is not possible in group chats 734 # OTR is not possible in group chats
735 return True 735 return True
736 from_jid = jid.JID(message_elt['from'])
737 if not from_jid.resource or from_jid.userhostJID() == client.jid.userhostJID():
738 # OTR is only usable when resources are present
739 return True
736 if client.profile in self.skipped_profiles: 740 if client.profile in self.skipped_profiles:
737 post_treat.addCallback(self._receivedTreatmentForSkippedProfiles) 741 post_treat.addCallback(self._receivedTreatmentForSkippedProfiles)
738 else: 742 else:
739 post_treat.addCallback(self._receivedTreatment, client) 743 post_treat.addCallback(self._receivedTreatment, client)
740 return True 744 return True