Mercurial > libervia-backend
comparison libervia/backend/plugins/plugin_xep_0376.py @ 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 | 0d7bb4df2343 |
children |
comparison
equal
deleted
inserted
replaced
4319:ef29fa1d9d69 | 4320:9658c534287e |
---|---|
57 | 57 |
58 def get_handler(self, client): | 58 def get_handler(self, client): |
59 return XEP_0376_Handler() | 59 return XEP_0376_Handler() |
60 | 60 |
61 async def profile_connected(self, client): | 61 async def profile_connected(self, client): |
62 if not self.host.hasFeature(client, NS_PAM): | 62 if not await self.host.memory.disco.has_feature(client, NS_PAM): |
63 log.warning( | 63 log.warning( |
64 "Your server doesn't support Pubsub Account Management, this is used to " | 64 "Your server doesn't support Pubsub Account Management, this is used to " |
65 "track all your subscriptions. You may ask your server administrator to " | 65 "track all your subscriptions. You may ask your server administrator to " |
66 "install it." | 66 "install it." |
67 ) | 67 ) |
103 service: jid.JID, | 103 service: jid.JID, |
104 nodeIdentifier: str, | 104 nodeIdentifier: str, |
105 sub_jid: Optional[jid.JID] = None, | 105 sub_jid: Optional[jid.JID] = None, |
106 options: Optional[dict] = None, | 106 options: Optional[dict] = None, |
107 ) -> Tuple[bool, Optional[pubsub.Subscription]]: | 107 ) -> Tuple[bool, Optional[pubsub.Subscription]]: |
108 if not self.host.hasFeature(client, NS_PAM) or client.is_component: | 108 if not await self.host.memory.disco.has_feature(client, NS_PAM) or client.is_component: |
109 return True, None | 109 return True, None |
110 | 110 |
111 await self._sub_request(client, service, nodeIdentifier, sub_jid, options, True) | 111 await self._sub_request(client, service, nodeIdentifier, sub_jid, options, True) |
112 | 112 |
113 # TODO: actual result is sent with <message> stanza, we have to get and use them | 113 # TODO: actual result is sent with <message> stanza, we have to get and use them |
125 nodeIdentifier: str, | 125 nodeIdentifier: str, |
126 sub_jid: Optional[jid.JID], | 126 sub_jid: Optional[jid.JID], |
127 subscriptionIdentifier: Optional[str], | 127 subscriptionIdentifier: Optional[str], |
128 sender: Optional[jid.JID] = None, | 128 sender: Optional[jid.JID] = None, |
129 ) -> bool: | 129 ) -> bool: |
130 if not self.host.hasFeature(client, NS_PAM) or client.is_component: | 130 if not await self.host.memory.disco.has_feature(client, NS_PAM) or client.is_component: |
131 return True | 131 return True |
132 await self._sub_request(client, service, nodeIdentifier, sub_jid, None, False) | 132 await self._sub_request(client, service, nodeIdentifier, sub_jid, None, False) |
133 return False | 133 return False |
134 | 134 |
135 async def subscriptions( | 135 async def subscriptions( |
136 self, | 136 self, |
137 client: SatXMPPEntity, | 137 client: SatXMPPEntity, |
138 service: Optional[jid.JID], | 138 service: Optional[jid.JID], |
139 node: str, | 139 node: str, |
140 ) -> Tuple[bool, Optional[List[Dict[str, Any]]]]: | 140 ) -> Tuple[bool, Optional[List[Dict[str, Any]]]]: |
141 if not self.host.hasFeature(client, NS_PAM): | 141 if not await self.host.has_feature(client, NS_PAM): |
142 return True, None | 142 return True, None |
143 if service is not None or node is not None: | 143 if service is not None or node is not None: |
144 # if we have service and/or node subscriptions, it's a regular XEP-0060 | 144 # if we have service and/or node subscriptions, it's a regular XEP-0060 |
145 # subscriptions request | 145 # subscriptions request |
146 return True, None | 146 return True, None |