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.
This commit is contained in:
Goffi 2024-09-30 14:14:38 +02:00
commit b9088dff79
2 changed files with 5 additions and 5 deletions

View file

@ -179,7 +179,7 @@ class XEP_0215:
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")

View file

@ -59,7 +59,7 @@ class XEP_0376:
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 @@ class XEP_0376:
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 @@ class XEP_0376:
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 @@ class XEP_0376:
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