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.
This commit is contained in:
Goffi 2021-02-04 21:05:21 +01:00
commit f15f09bb70

View file

@ -112,9 +112,9 @@ class PubsubSchema(object):
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 @@ class PubsubSchema(object):
_("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 @@ class PubsubSchema(object):
items_data = await self._p.getItems(
client,
service,
nodeIdentifier,
submitted_ns,
max_items,
item_ids,
sub_id,
@ -659,6 +660,7 @@ class PubsubSchema(object):
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