Mercurial > libervia-backend
changeset 3993:722c25818778
plugin XEP-0470: create a default configuration if node config can't be accessed
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 05 Dec 2022 11:54:47 +0100 |
parents | 1c84268752a1 |
children | 69d970f974ff |
files | sat/plugins/plugin_xep_0060.py sat/plugins/plugin_xep_0470.py |
diffstat | 2 files changed, 11 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0060.py Fri Nov 25 16:34:09 2022 +0100 +++ b/sat/plugins/plugin_xep_0060.py Mon Dec 05 11:54:47 2022 +0100 @@ -961,6 +961,14 @@ d.addCallback(cb) return d + def make_configuration_form(self, options: dict) -> data_form.Form: + """Build a configuration form""" + form = data_form.Form( + formType="submit", formNamespace=pubsub.NS_PUBSUB_NODE_CONFIG + ) + form.makeFields(options) + return form + def _setNodeConfiguration(self, service_s, nodeIdentifier, options, profile_key): client = self.host.getClient(profile_key) d = self.setConfiguration( @@ -973,10 +981,7 @@ request.recipient = service request.nodeIdentifier = nodeIdentifier - form = data_form.Form( - formType="submit", formNamespace=pubsub.NS_PUBSUB_NODE_CONFIG - ) - form.makeFields(options) + form = self.make_configuration_form(options) request.options = form d = request.send(client.xmlstream)
--- a/sat/plugins/plugin_xep_0470.py Fri Nov 25 16:34:09 2022 +0100 +++ b/sat/plugins/plugin_xep_0470.py Mon Dec 05 11:54:47 2022 +0100 @@ -194,6 +194,8 @@ client, service, node ) node_config = await self._p.getConfiguration(client, service, node) + elif e.condition == "forbidden": + node_config = self._p.make_configuration_form({}) else: raise e try: