diff sat/plugins/plugin_xep_0346.py @ 3457:6791103de47d

plugin XEP-0346: use submitted namespace for node: the node was not always adapted to the submitted namespace now used with XEP-0346, this patch fixes it by adding the prefix when it's missing.
author Goffi <goffi@goffi.org>
date Thu, 04 Feb 2021 21:05:21 +0100
parents bb0225aaf4e6
children d4a71a1dac88
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0346.py	Thu Feb 04 21:05:21 2021 +0100
+++ b/sat/plugins/plugin_xep_0346.py	Thu Feb 04 21:05:21 2021 +0100
@@ -112,9 +112,9 @@
             namespace = namespace[len(TEMPLATE_PREFIX):]
         return namespace
 
-    def getSubmittedNS(self, app_ns: str) -> str:
+    def getSubmittedNS(self, namespace: str) -> str:
         """Returns node to use to submit forms"""
-        return f"{SUBMITTED_PREFIX}{app_ns}"
+        return f"{SUBMITTED_PREFIX}{self.getApplicationNS(namespace)}"
 
     def _getSchemaBridgeCb(self, schema_elt):
         if schema_elt is None:
@@ -300,6 +300,7 @@
                     _("default_node must be set if nodeIdentifier is not set")
                 )
             nodeIdentifier = default_node
+        submitted_ns = self.getSubmittedNS(nodeIdentifier)
         # we need the initial form to get options of fields when suitable
         schema_form = await self.getSchemaForm(
             client, service, nodeIdentifier, schema, form_type="result", copy_form=False
@@ -307,7 +308,7 @@
         items_data = await self._p.getItems(
             client,
             service,
-            nodeIdentifier,
+            submitted_ns,
             max_items,
             item_ids,
             sub_id,
@@ -659,6 +660,7 @@
             if default_node is None:
                 raise ValueError(_("default_node must be set if node is not set"))
             node = default_node
+        node = self.getSubmittedNS(node)
         now = utils.xmpp_date()
         if not item_id:
             values["created"] = now