# HG changeset patch # User Matthew Wild # Date 1638781419 0 # Node ID 2762abec4c63ebfc99185b37bac848e2a9ff370a # Parent a9be85b2da17b425b4cb64ad385efb341a071bba pubsub: Allow setting additional attributes in pubsub action elements diff -r a9be85b2da17 -r 2762abec4c63 plugins/pubsub.lua --- a/plugins/pubsub.lua Thu Oct 22 15:28:35 2020 +0100 +++ b/plugins/pubsub.lua Mon Dec 06 09:03:39 2021 +0000 @@ -58,11 +58,19 @@ -- Helper function for iq+pubsub tags -local function pubsub_iq(iq_type, to, ns, op, node, jid, item_id) +local function pubsub_iq(iq_type, to, ns, op, node, jid, item_id, op_attr_extra) local st = verse.iq{ type = iq_type or "get", to = to } :tag("pubsub", { xmlns = ns or xmlns_pubsub }) -- ns would be ..#owner - if op then st:tag(op, { node = node, jid = jid }); end - if item_id then st:tag("item", { id = item_id ~= true and item_id or nil }); end + local op_attr = { node = node, jid = jid }; + if op_attr_extra then + for k, v in pairs(op_attr_extra) do + op_attr[k] = v; + end + end + if op then st:tag(op, op_attr); end + if item_id then + st:tag("item", { id = item_id ~= true and item_id or nil }); + end return st; end