Diff

plugins/mod_pubsub/mod_pubsub.lua @ 8814:07197f29e2b8

mod_pubsub: Make the 'type' attribute on broadcast messages configurable This adds support for the pubsub#notification_type field in the node config form.
author Kim Alvefur <zash@zash.se>
date Mon, 21 May 2018 00:35:45 +0200
parent 8811:f2d35eee69c9
child 8815:5974c9da1391
line wrap: on
line diff
--- a/plugins/mod_pubsub/mod_pubsub.lua	Mon May 21 00:35:00 2018 +0200
+++ b/plugins/mod_pubsub/mod_pubsub.lua	Mon May 21 00:35:45 2018 +0200
@@ -41,7 +41,7 @@
 end
 
 
-function simple_broadcast(kind, node, jids, item, actor)
+function simple_broadcast(kind, node, jids, item, actor, node_obj)
 	if item then
 		item = st.clone(item);
 		item.attr.xmlns = nil; -- Clear the pubsub namespace
@@ -51,10 +51,12 @@
 	end
 
 	local id = new_id();
-	local message = st.message({ from = module.host, type = "headline", id = id })
+	local msg_type = node_obj and node_obj.config.message_type or "headline";
+	local message = st.message({ from = module.host, type = msg_type, id = id })
 		:tag("event", { xmlns = xmlns_pubsub_event })
 			:tag(kind, { node = node })
 				:add_child(item);
+
 	module:broadcast(jids, message, pairs);
 end