diff sat/plugins/plugin_xep_0060.py @ 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 cd4d95b3fed3
children 9456852d3286
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)