Changeset

437:2762abec4c63

pubsub: Allow setting additional attributes in pubsub action elements
author Matthew Wild <mwild1@gmail.com>
date Mon, 06 Dec 2021 09:03:39 +0000
parents 436:a9be85b2da17
children 438:98dc1750584d
files plugins/pubsub.lua
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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