Diff

plugins/mod_pubsub/mod_pubsub.lua @ 6515:c9a72c64c3e2

mod_pubsub: Add support for including the publisher in item broadcasts
author Philipp Hancke <fippo@goodadvice.pages.de>
date Thu, 20 Nov 2014 09:01:45 +0000
parent 6446:011ca9b88179
child 6516:ecd8d6437053
child 6657:f1af4edd5722
line wrap: on
line diff
--- a/plugins/mod_pubsub/mod_pubsub.lua	Sun Nov 09 20:30:04 2014 +0100
+++ b/plugins/mod_pubsub/mod_pubsub.lua	Thu Nov 20 09:01:45 2014 +0000
@@ -11,6 +11,7 @@
 local autocreate_on_subscribe = module:get_option_boolean("autocreate_on_subscribe", false);
 local pubsub_disco_name = module:get_option("name");
 if type(pubsub_disco_name) ~= "string" then pubsub_disco_name = "Prosody PubSub Service"; end
+local expose_publisher = module:get_option_boolean("expose_publisher", false)
 
 local service;
 
@@ -36,10 +37,13 @@
 	end
 end
 
-function simple_broadcast(kind, node, jids, item)
+function simple_broadcast(kind, node, jids, item, actor)
 	if item then
 		item = st.clone(item);
 		item.attr.xmlns = nil; -- Clear the pubsub namespace
+		if expose_publisher and actor then
+			item.attr.publisher = actor
+		end
 	end
 	local message = st.message({ from = module.host, type = "headline" })
 		:tag("event", { xmlns = xmlns_pubsub_event })