diff src/plugins/plugin_xep_0184.py @ 2140:f79935f41125

plugin XEP-0184: check if entity is allowed to see our presence before returning receipt
author Goffi <goffi@goffi.org>
date Mon, 06 Feb 2017 20:47:36 +0100
parents 6a66c8c5a567
children 1d3f73e065e1
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0184.py	Mon Feb 06 20:46:59 2017 +0100
+++ b/src/plugins/plugin_xep_0184.py	Mon Feb 06 20:47:36 2017 +0100
@@ -19,7 +19,7 @@
 from sat.core.i18n import _
 from sat.core.log import getLogger
 from twisted.internet import reactor
-from twisted.words.protocols.jabber import xmlstream
+from twisted.words.protocols.jabber import xmlstream, jid
 from twisted.words.xish import domish
 log = getLogger(__name__)
 
@@ -121,8 +121,9 @@
         """This method is called on message delivery receipts **request** (XEP-0184 #7)
         @param msg_elt: message element
         @param client: %(doc_client)s"""
+        from_jid = jid.JID(msg_elt['from'])
 
-        if self._isActif(client.profile):
+        if self._isActif(client.profile) and client.roster.isPresenceAuthorised(from_jid):
             received_elt_ret = domish.Element((NS_MESSAGE_DELIVERY_RECEIPTS, 'received'))
             received_elt_ret["id"] = msg_elt["id"]