diff --git a/sat/plugins/plugin_xep_0050.py b/sat/plugins/plugin_xep_0050.py index 64bf390f..737426dd 100644 --- a/sat/plugins/plugin_xep_0050.py +++ b/sat/plugins/plugin_xep_0050.py @@ -88,19 +88,11 @@ class AdHocCommand(XMPPHandler): self.label = label self.node = node self.features = [disco.DiscoFeature(feature) for feature in features] - ( - self.allowed_jids, - self.allowed_groups, - self.allowed_magics, - self.forbidden_jids, - self.forbidden_groups, - ) = ( - allowed_jids, - allowed_groups, - allowed_magics, - forbidden_jids, - forbidden_groups, - ) + self.allowed_jids = allowed_jids + self.allowed_groups = allowed_groups + self.allowed_magics = allowed_magics + self.forbidden_jids = forbidden_jids + self.forbidden_groups = forbidden_groups self.sessions = Sessions(timeout=timeout) @property @@ -624,12 +616,11 @@ class XEP_0050(object): def _run(self, service_jid_s="", node="", profile_key=C.PROF_KEY_NONE): client = self.host.getClient(profile_key) service_jid = jid.JID(service_jid_s) if service_jid_s else None - d = self.run(client, service_jid, node or None) + d = defer.ensureDeferred(self.run(client, service_jid, node or None)) d.addCallback(lambda xmlui: xmlui.toXml()) return d - @defer.inlineCallbacks - def run(self, client, service_jid=None, node=None): + async def run(self, client, service_jid=None, node=None): """Run an ad-hoc command @param service_jid(jid.JID, None): jid of the ad-hoc service @@ -643,16 +634,16 @@ class XEP_0050(object): session_id, session_data = self.requesting.newSession(profile=client.profile) session_data["jid"] = service_jid if node is None: - xmlui = yield self.listUI(client, service_jid) + xmlui = await self.listUI(client, service_jid) else: session_data["node"] = node - cb_data = yield self.requestingEntity( + cb_data = await self.requestingEntity( {"session_id": session_id}, client.profile ) xmlui = cb_data["xmlui"] xmlui.session_id = session_id - defer.returnValue(xmlui) + return xmlui def list(self, client, to_jid): """Request available commands