Mercurial > libervia-backend
comparison libervia/backend/plugins/plugin_comp_ap_gateway/ad_hoc.py @ 4270:0d7bb4df2343
Reformatted code base using black.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 19 Jun 2024 18:44:57 +0200 |
parents | 4b842c1fb686 |
children |
comparison
equal
deleted
inserted
replaced
4269:64a85ce8be70 | 4270:0d7bb4df2343 |
---|---|
27 | 27 |
28 | 28 |
29 log = getLogger(__name__) | 29 log = getLogger(__name__) |
30 NS_XMPP_JID_NODE_2_AP = "https://libervia.org/ap_gateway/xmpp_jid_node_2_ap_actor" | 30 NS_XMPP_JID_NODE_2_AP = "https://libervia.org/ap_gateway/xmpp_jid_node_2_ap_actor" |
31 | 31 |
32 | |
32 class APAdHocService: | 33 class APAdHocService: |
33 """Ad-Hoc commands for AP Gateway""" | 34 """Ad-Hoc commands for AP Gateway""" |
34 | 35 |
35 def __init__(self, apg): | 36 def __init__(self, apg): |
36 self.host = apg.host | 37 self.host = apg.host |
50 self, | 51 self, |
51 client: SatXMPPEntity, | 52 client: SatXMPPEntity, |
52 command_elt: domish.Element, | 53 command_elt: domish.Element, |
53 session_data: dict, | 54 session_data: dict, |
54 action: str, | 55 action: str, |
55 node: str | 56 node: str, |
56 ): | 57 ): |
57 try: | 58 try: |
58 x_elt = next(command_elt.elements(data_form.NS_X_DATA, "x")) | 59 x_elt = next(command_elt.elements(data_form.NS_X_DATA, "x")) |
59 command_form = data_form.Form.fromElement(x_elt) | 60 command_form = data_form.Form.fromElement(x_elt) |
60 except StopIteration: | 61 except StopIteration: |
61 command_form = None | 62 command_form = None |
62 if command_form is None or len(command_form.fields) == 0: | 63 if command_form is None or len(command_form.fields) == 0: |
63 # root request | 64 # root request |
64 status = self._c.STATUS.EXECUTING | 65 status = self._c.STATUS.EXECUTING |
65 form = data_form.Form( | 66 form = data_form.Form( |
66 "form", title="XMPP JID/node to AP actor conversion", | 67 "form", |
67 formNamespace=NS_XMPP_JID_NODE_2_AP | 68 title="XMPP JID/node to AP actor conversion", |
69 formNamespace=NS_XMPP_JID_NODE_2_AP, | |
68 ) | 70 ) |
69 | 71 |
70 field = data_form.Field( | 72 field = data_form.Field("text-single", "jid", required=True) |
71 "text-single", "jid", required=True | |
72 ) | |
73 form.addField(field) | 73 form.addField(field) |
74 | 74 |
75 field = data_form.Field( | 75 field = data_form.Field("text-single", "node", required=False) |
76 "text-single", "node", required=False | |
77 ) | |
78 form.addField(field) | 76 form.addField(field) |
79 | 77 |
80 payload = form.toElement() | 78 payload = form.toElement() |
81 return payload, status, None, None | 79 return payload, status, None, None |
82 else: | 80 else: |