JC Brand hace 4 años
padre
commit
3fc6f7fa23

+ 1 - 0
CHANGES.md

@@ -19,6 +19,7 @@ Soon we'll deprecate the latter, so prepare now.
     and [muc_roomid_policy_hint](https://conversejs.org/docs/html/configuration.html#muc-roomid-policy-hint)
     and [muc_roomid_policy_hint](https://conversejs.org/docs/html/configuration.html#muc-roomid-policy-hint)
 - #1826: A user can now add himself as a contact
 - #1826: A user can now add himself as a contact
 - #1839: Headline messages are shown in controlbox
 - #1839: Headline messages are shown in controlbox
+- #1924: Configuring an ejabberd room fails
 - #1896: Don't send receipts for messages fetched from the archive
 - #1896: Don't send receipts for messages fetched from the archive
 - #1937: Editing a message removes the mentions highlight
 - #1937: Editing a message removes the mentions highlight
 - #1963: Mentions are visually incorrect when used in message replies
 - #1963: Mentions are visually incorrect when used in message replies

+ 4 - 3
src/components/adhoc-commands.js

@@ -210,9 +210,10 @@ export default class AdHocCommands extends CustomElement {
 
 
         const cmd = this.commands.filter(c => c.node === node)[0];
         const cmd = this.commands.filter(c => c.node === node)[0];
         const inputs = sizzle(':input:not([type=button]):not([type=submit])', ev.target);
         const inputs = sizzle(':input:not([type=button]):not([type=submit])', ev.target);
-        const configArray = inputs
+        const config_array = inputs
             .filter(i => !['command_jid', 'command_node'].includes(i.getAttribute('name')))
             .filter(i => !['command_jid', 'command_node'].includes(i.getAttribute('name')))
-            .map(u.webForm2xForm);
+            .map(u.webForm2xForm)
+            .filter(n => n);
 
 
         const iq = $iq({to: jid, type: "set"})
         const iq = $iq({to: jid, type: "set"})
             .c("command", {
             .c("command", {
@@ -220,7 +221,7 @@ export default class AdHocCommands extends CustomElement {
                 'node': cmd.node,
                 'node': cmd.node,
                 'xmlns': Strophe.NS.ADHOC
                 'xmlns': Strophe.NS.ADHOC
             }).c("x", {xmlns: Strophe.NS.XFORM, type: "submit"});
             }).c("x", {xmlns: Strophe.NS.XFORM, type: "submit"});
-        configArray.forEach(node => iq.cnode(node).up());
+        config_array.forEach(node => iq.cnode(node).up());
 
 
         let result;
         let result;
         try {
         try {

+ 3 - 4
src/converse-muc-views.js

@@ -1088,7 +1088,6 @@ export const ChatRoomView = ChatBoxView.extend({
         this.hideChatRoomContents();
         this.hideChatRoomContents();
         this.model.save('config_stanza', stanza.outerHTML);
         this.model.save('config_stanza', stanza.outerHTML);
         if (!this.config_form) {
         if (!this.config_form) {
-            const { _converse } = this.__super__;
             this.config_form = new _converse.MUCConfigForm({
             this.config_form = new _converse.MUCConfigForm({
                 'model': this.model,
                 'model': this.model,
                 'chatroomview': this
                 'chatroomview': this
@@ -1511,15 +1510,15 @@ converse.plugins.add('converse-muc-views', {
             async submitConfigForm (ev) {
             async submitConfigForm (ev) {
                 ev.preventDefault();
                 ev.preventDefault();
                 const inputs = sizzle(':input:not([type=button]):not([type=submit])', ev.target);
                 const inputs = sizzle(':input:not([type=button]):not([type=submit])', ev.target);
-                const configArray = inputs.map(u.webForm2xForm);
+                const config_array = inputs.map(u.webForm2xForm).filter(f => f);
                 try {
                 try {
-                    await this.model.sendConfiguration(configArray);
+                    await this.model.sendConfiguration(config_array);
                 } catch (e) {
                 } catch (e) {
                     log.error(e);
                     log.error(e);
                     const message =
                     const message =
                         __("Sorry, an error occurred while trying to submit the config form.") + " " +
                         __("Sorry, an error occurred while trying to submit the config form.") + " " +
                         __("Check your browser's developer console for details.");
                         __("Check your browser's developer console for details.");
-                    this.model.createMessage({message, 'type': 'error'});
+                    api.alert('error', __('Error'), message);
                 }
                 }
                 await this.model.refreshDiscoInfo();
                 await this.model.refreshDiscoInfo();
                 this.chatroomview.closeForm();
                 this.chatroomview.closeForm();

+ 3 - 1
src/converse-register.js

@@ -556,7 +556,9 @@ converse.plugins.add('converse-register', {
 
 
                 if (this.form_type === 'xform') {
                 if (this.form_type === 'xform') {
                     iq.c("x", {xmlns: Strophe.NS.XFORM, type: 'submit'});
                     iq.c("x", {xmlns: Strophe.NS.XFORM, type: 'submit'});
-                    inputs.forEach(input => iq.cnode(utils.webForm2xForm(input)).up());
+
+                    const xml_nodes = inputs.map(i => utils.webForm2xForm(i)).filter(n => n);
+                    xml_nodes.forEach(n => iq.cnode(n).up());
                 } else {
                 } else {
                     inputs.forEach(input => iq.c(input.getAttribute('name'), {}, input.value));
                     inputs.forEach(input => iq.c(input.getAttribute('name'), {}, input.value));
                 }
                 }

+ 5 - 6
src/headless/utils/form.js

@@ -13,6 +13,10 @@ import u from "./core";
  * @param { DOMElement } field - the field to convert
  * @param { DOMElement } field - the field to convert
  */
  */
 u.webForm2xForm = function (field) {
 u.webForm2xForm = function (field) {
+    const name = field.getAttribute('name');
+    if (!name) {
+        return null; // See #1924
+    }
     let value;
     let value;
     if (field.getAttribute('type') === 'checkbox') {
     if (field.getAttribute('type') === 'checkbox') {
         value = field.checked && 1 || 0;
         value = field.checked && 1 || 0;
@@ -23,11 +27,6 @@ u.webForm2xForm = function (field) {
     } else {
     } else {
         value = field.value;
         value = field.value;
     }
     }
-    return u.stringToNode(
-        tpl_field({
-            'name': field.getAttribute('name'),
-            'value': value
-        })
-    );
+    return u.stringToNode(tpl_field({ name, value }));
 };
 };
 export default u;
 export default u;