pubsub: Allow setting additional attributes in pubsub action elements

Mon, 06 Dec 2021 09:03:39 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Mon, 06 Dec 2021 09:03:39 +0000
changeset 437
2762abec4c63
parent 436
a9be85b2da17
child 438
98dc1750584d

pubsub: Allow setting additional attributes in pubsub action elements

plugins/pubsub.lua file | annotate | diff | comparison | revisions
--- 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
 

mercurial