Skip to content

Commit

Permalink
Bugfix. Improper fallback to empty array
Browse files Browse the repository at this point in the history
Updates #3155
  • Loading branch information
jcbrand committed Apr 2, 2024
1 parent 85e5f0f commit 7790830
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/headless/plugins/adhoc/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { Strophe, u } = converse.env;
*/
export function parseForCommands (stanza) {
const items = sizzle(`query[xmlns="${Strophe.NS.DISCO_ITEMS}"][node="${Strophe.NS.ADHOC}"] item`, stanza);
return items.map(u.getAttributes)
return items.map(u.getAttributes);
}

/**
Expand All @@ -20,9 +20,10 @@ export function getCommandFields (iq, jid) {
const data = {
sessionid: cmd_el.getAttribute('sessionid'),
instructions: sizzle('x[type="form"][xmlns="jabber:x:data"] instructions', cmd_el).pop()?.textContent,
fields: sizzle('x[type="form"][xmlns="jabber:x:data"] field', cmd_el)
.map(f => u.xForm2TemplateResult(f, cmd_el, { domain: jid })),
actions: Array.from(cmd_el.querySelector('actions')?.children).map((a) => a.nodeName.toLowerCase()) ?? []
}
fields: sizzle('x[type="form"][xmlns="jabber:x:data"] field', cmd_el).map((f) =>
u.xForm2TemplateResult(f, cmd_el, { domain: jid })
),
actions: Array.from(cmd_el.querySelector('actions')?.children ?? []).map((a) => a.nodeName.toLowerCase()),
};
return data;
}

0 comments on commit 7790830

Please sign in to comment.