changeset 3585:31628770a15a

core (xmpp): renamed `SatRosterProtocol.presenceSubscribed` to `isSubscribedFrom` (and added `isSubscribedTo`)
author Goffi <goffi@goffi.org>
date Wed, 28 Jul 2021 22:15:31 +0200
parents edc79cefe968
children 5f65f4e9f8cb
files sat/core/xmpp.py sat/plugins/plugin_xep_0184.py
diffstat 2 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/sat/core/xmpp.py	Wed Jun 30 16:19:14 2021 +0200
+++ b/sat/core/xmpp.py	Wed Jul 28 22:15:31 2021 +0200
@@ -1552,7 +1552,7 @@
                 f"a JID is expected, not {type(entity_jid)}: {entity_jid!r}")
         return entity_jid in self._jids
 
-    def isPresenceAuthorised(self, entity_jid):
+    def isSubscribedFrom(self, entity_jid: jid.JID) -> bool:
         """Return True if entity is authorised to see our presence"""
         try:
             item = self._jids[entity_jid.userhostJID()]
@@ -1560,6 +1560,14 @@
             return False
         return item.subscriptionFrom
 
+    def isSubscribedTo(self, entity_jid: jid.JID) -> bool:
+        """Return True if we are subscribed to entity"""
+        try:
+            item = self._jids[entity_jid.userhostJID()]
+        except KeyError:
+            return False
+        return item.subscriptionTo
+
     def getItems(self):
         """Return all items of the roster"""
         return list(self._jids.values())
--- a/sat/plugins/plugin_xep_0184.py	Wed Jun 30 16:19:14 2021 +0200
+++ b/sat/plugins/plugin_xep_0184.py	Wed Jul 28 22:15:31 2021 +0200
@@ -150,7 +150,7 @@
         @param client: %(doc_client)s"""
         from_jid = jid.JID(msg_elt["from"])
 
-        if self._isActif(client.profile) and client.roster.isPresenceAuthorised(from_jid):
+        if self._isActif(client.profile) and client.roster.isSubscribedFrom(from_jid):
             received_elt_ret = domish.Element((NS_MESSAGE_DELIVERY_RECEIPTS, "received"))
             try:
                 received_elt_ret["id"] = msg_elt["id"]