aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Hancke <fippo@goodadvice.pages.de>2014-11-20 09:01:45 +0000
committerPhilipp Hancke <fippo@goodadvice.pages.de>2014-11-20 09:01:45 +0000
commit958a4e177ba331c8a1e6ccd333ab5892a8f86bfc (patch)
treef418eb9a9dcd34b9c9c28aa74bc20340b0e708a9
parent486335f3dbc84dacf253120f544f1d2ee026cf94 (diff)
downloadprosody-958a4e177ba331c8a1e6ccd333ab5892a8f86bfc.tar.gz
prosody-958a4e177ba331c8a1e6ccd333ab5892a8f86bfc.zip
mod_pubsub: Add support for including the publisher in item broadcasts
-rw-r--r--plugins/mod_pubsub/mod_pubsub.lua6
-rw-r--r--util/pubsub.lua2
2 files changed, 6 insertions, 2 deletions
diff --git a/plugins/mod_pubsub/mod_pubsub.lua b/plugins/mod_pubsub/mod_pubsub.lua
index 8c777f54..de027b58 100644
--- a/plugins/mod_pubsub/mod_pubsub.lua
+++ b/plugins/mod_pubsub/mod_pubsub.lua
@@ -11,6 +11,7 @@ local autocreate_on_publish = module:get_option_boolean("autocreate_on_publish",
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 @@ function handle_pubsub_iq(event)
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 })
diff --git a/util/pubsub.lua b/util/pubsub.lua
index 2f8525b6..c15a41d7 100644
--- a/util/pubsub.lua
+++ b/util/pubsub.lua
@@ -294,7 +294,7 @@ function service:publish(node, actor, id, item)
node_data[id] = item;
trim_items(node_data, node_obj.config["pubsub#max_items"]);
self.events.fire_event("item-published", { node = node, actor = actor, id = id, item = item });
- self.config.broadcaster("items", node, node_obj.subscribers, item);
+ self.config.broadcaster("items", node, node_obj.subscribers, item, actor);
return true;
end