Mercurial > libervia-backend
changeset 4320:9658c534287e
plugin XEP-0215, XEP-0376: fix bad calls to `hasFeature`:
`hasFeature` was called like blocking code, missing the `await`. This has been fixed, and
is now using the `memory.disco.has_feature` version.
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 30 Sep 2024 14:14:38 +0200 |
parents | ef29fa1d9d69 |
children | 2246eeeccc74 |
files | libervia/backend/plugins/plugin_xep_0215.py libervia/backend/plugins/plugin_xep_0376.py |
diffstat | 2 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/libervia/backend/plugins/plugin_xep_0215.py Sat Sep 28 16:00:16 2024 +0200 +++ b/libervia/backend/plugins/plugin_xep_0215.py Mon Sep 30 14:14:38 2024 +0200 @@ -179,7 +179,7 @@ try: cached_services = client._xep_0215_services[entity] except KeyError: - if not self.host.hasFeature(client, NS_EXTDISCO, entity): + if not await self.host.memory.disco.has_feature(client, NS_EXTDISCO, entity): cached_services = client._xep_0215_services[entity] = None else: iq_elt = client.IQ("get")
--- a/libervia/backend/plugins/plugin_xep_0376.py Sat Sep 28 16:00:16 2024 +0200 +++ b/libervia/backend/plugins/plugin_xep_0376.py Mon Sep 30 14:14:38 2024 +0200 @@ -59,7 +59,7 @@ return XEP_0376_Handler() async def profile_connected(self, client): - if not self.host.hasFeature(client, NS_PAM): + if not await self.host.memory.disco.has_feature(client, NS_PAM): log.warning( "Your server doesn't support Pubsub Account Management, this is used to " "track all your subscriptions. You may ask your server administrator to " @@ -105,7 +105,7 @@ sub_jid: Optional[jid.JID] = None, options: Optional[dict] = None, ) -> Tuple[bool, Optional[pubsub.Subscription]]: - if not self.host.hasFeature(client, NS_PAM) or client.is_component: + if not await self.host.memory.disco.has_feature(client, NS_PAM) or client.is_component: return True, None await self._sub_request(client, service, nodeIdentifier, sub_jid, options, True) @@ -127,7 +127,7 @@ subscriptionIdentifier: Optional[str], sender: Optional[jid.JID] = None, ) -> bool: - if not self.host.hasFeature(client, NS_PAM) or client.is_component: + if not await self.host.memory.disco.has_feature(client, NS_PAM) or client.is_component: return True await self._sub_request(client, service, nodeIdentifier, sub_jid, None, False) return False @@ -138,7 +138,7 @@ service: Optional[jid.JID], node: str, ) -> Tuple[bool, Optional[List[Dict[str, Any]]]]: - if not self.host.hasFeature(client, NS_PAM): + if not await self.host.has_feature(client, NS_PAM): return True, None if service is not None or node is not None: # if we have service and/or node subscriptions, it's a regular XEP-0060