From fcbbc2aeed1feeba14c8835628b6791aea981086 Mon Sep 17 00:00:00 2001 From: Goffi Date: Wed, 28 Jul 2021 22:15:31 +0200 Subject: [PATCH] core (xmpp): renamed `SatRosterProtocol.presenceSubscribed` to `isSubscribedFrom` (and added `isSubscribedTo`) --- sat/core/xmpp.py | 10 +++++++++- sat/plugins/plugin_xep_0184.py | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/sat/core/xmpp.py b/sat/core/xmpp.py index c4450631..67798fe9 100644 --- a/sat/core/xmpp.py +++ b/sat/core/xmpp.py @@ -1552,7 +1552,7 @@ class SatRosterProtocol(xmppim.RosterClientProtocol): 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 @@ class SatRosterProtocol(xmppim.RosterClientProtocol): 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()) diff --git a/sat/plugins/plugin_xep_0184.py b/sat/plugins/plugin_xep_0184.py index 6b174914..5b2153dd 100644 --- a/sat/plugins/plugin_xep_0184.py +++ b/sat/plugins/plugin_xep_0184.py @@ -150,7 +150,7 @@ class XEP_0184(object): @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"]