Commit 3fc6f7fa authored by JC Brand's avatar JC Brand

Fixes #1924

parent 3a88831b
......@@ -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)
- #1826: A user can now add himself as a contact
- #1839: Headline messages are shown in controlbox
- #1924: Configuring an ejabberd room fails
- #1896: Don't send receipts for messages fetched from the archive
- #1937: Editing a message removes the mentions highlight
- #1963: Mentions are visually incorrect when used in message replies
......
......@@ -210,9 +210,10 @@ export default class AdHocCommands extends CustomElement {
const cmd = this.commands.filter(c => c.node === node)[0];
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')))
.map(u.webForm2xForm);
.map(u.webForm2xForm)
.filter(n => n);
const iq = $iq({to: jid, type: "set"})
.c("command", {
......@@ -220,7 +221,7 @@ export default class AdHocCommands extends CustomElement {
'node': cmd.node,
'xmlns': Strophe.NS.ADHOC
}).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;
try {
......
......@@ -1088,7 +1088,6 @@ export const ChatRoomView = ChatBoxView.extend({
this.hideChatRoomContents();
this.model.save('config_stanza', stanza.outerHTML);
if (!this.config_form) {
const { _converse } = this.__super__;
this.config_form = new _converse.MUCConfigForm({
'model': this.model,
'chatroomview': this
......@@ -1511,15 +1510,15 @@ converse.plugins.add('converse-muc-views', {
async submitConfigForm (ev) {
ev.preventDefault();
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 {
await this.model.sendConfiguration(configArray);
await this.model.sendConfiguration(config_array);
} catch (e) {
log.error(e);
const message =
__("Sorry, an error occurred while trying to submit the config form.") + " " +
__("Check your browser's developer console for details.");
this.model.createMessage({message, 'type': 'error'});
api.alert('error', __('Error'), message);
}
await this.model.refreshDiscoInfo();
this.chatroomview.closeForm();
......
......@@ -556,7 +556,9 @@ converse.plugins.add('converse-register', {
if (this.form_type === 'xform') {
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 {
inputs.forEach(input => iq.c(input.getAttribute('name'), {}, input.value));
}
......
......@@ -13,6 +13,10 @@ import u from "./core";
* @param { DOMElement } field - the field to convert
*/
u.webForm2xForm = function (field) {
const name = field.getAttribute('name');
if (!name) {
return null; // See #1924
}
let value;
if (field.getAttribute('type') === 'checkbox') {
value = field.checked && 1 || 0;
......@@ -23,11 +27,6 @@ u.webForm2xForm = function (field) {
} else {
value = field.value;
}
return u.stringToNode(
tpl_field({
'name': field.getAttribute('name'),
'value': value
})
);
return u.stringToNode(tpl_field({ name, value }));
};
export default u;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment