Comparison

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
comparison
equal deleted inserted replaced
6510:8273236a995f 6515:c9a72c64c3e2
9 9
10 local autocreate_on_publish = module:get_option_boolean("autocreate_on_publish", false); 10 local autocreate_on_publish = module:get_option_boolean("autocreate_on_publish", false);
11 local autocreate_on_subscribe = module:get_option_boolean("autocreate_on_subscribe", false); 11 local autocreate_on_subscribe = module:get_option_boolean("autocreate_on_subscribe", false);
12 local pubsub_disco_name = module:get_option("name"); 12 local pubsub_disco_name = module:get_option("name");
13 if type(pubsub_disco_name) ~= "string" then pubsub_disco_name = "Prosody PubSub Service"; end 13 if type(pubsub_disco_name) ~= "string" then pubsub_disco_name = "Prosody PubSub Service"; end
14 local expose_publisher = module:get_option_boolean("expose_publisher", false)
14 15
15 local service; 16 local service;
16 17
17 local lib_pubsub = module:require "pubsub"; 18 local lib_pubsub = module:require "pubsub";
18 local handlers = lib_pubsub.handlers; 19 local handlers = lib_pubsub.handlers;
34 handler(origin, stanza, action, service); 35 handler(origin, stanza, action, service);
35 return true; 36 return true;
36 end 37 end
37 end 38 end
38 39
39 function simple_broadcast(kind, node, jids, item) 40 function simple_broadcast(kind, node, jids, item, actor)
40 if item then 41 if item then
41 item = st.clone(item); 42 item = st.clone(item);
42 item.attr.xmlns = nil; -- Clear the pubsub namespace 43 item.attr.xmlns = nil; -- Clear the pubsub namespace
44 if expose_publisher and actor then
45 item.attr.publisher = actor
46 end
43 end 47 end
44 local message = st.message({ from = module.host, type = "headline" }) 48 local message = st.message({ from = module.host, type = "headline" })
45 :tag("event", { xmlns = xmlns_pubsub_event }) 49 :tag("event", { xmlns = xmlns_pubsub_event })
46 :tag(kind, { node = node }) 50 :tag(kind, { node = node })
47 :add_child(item); 51 :add_child(item);