mod_pubsub: Add support for thin notifications (without the full payload)
authorKim Alvefur <zash@zash.se>
Thu, 16 Aug 2018 15:20:29 +0200
changeset 9191 ef2616ade453
parent 9190 bd452e4f5a13
child 9192 8fadd3d6c8d3
mod_pubsub: Add support for thin notifications (without the full payload)
plugins/mod_pubsub/mod_pubsub.lua
plugins/mod_pubsub/pubsub.lib.lua
--- a/plugins/mod_pubsub/mod_pubsub.lua	Thu Aug 16 15:18:29 2018 +0200
+++ b/plugins/mod_pubsub/mod_pubsub.lua	Thu Aug 16 15:20:29 2018 +0200
@@ -60,6 +60,9 @@
 		item = st.clone(item);
 		item.attr.xmlns = nil; -- Clear the pubsub namespace
 		if kind == "items" then
+			if node_obj and node_obj.config.include_payload == false then
+				item:maptags(function () return nil; end);
+			end
 			if expose_publisher and actor then
 				item.attr.publisher = actor
 			end
--- a/plugins/mod_pubsub/pubsub.lib.lua	Thu Aug 16 15:18:29 2018 +0200
+++ b/plugins/mod_pubsub/pubsub.lib.lua	Thu Aug 16 15:20:29 2018 +0200
@@ -104,6 +104,11 @@
 		name = "pubsub#deliver_notifications";
 	};
 	{
+		type = "boolean";
+		label = "Whether to deliver payloads with event notifications";
+		name = "pubsub#deliver_payloads";
+	};
+	{
 		type = "list-single";
 		name = "pubsub#notification_type";
 		label = "Specify the delivery style for notifications";
@@ -171,6 +176,7 @@
 	notify_items = "pubsub#deliver_notifications";
 	notify_delete = "pubsub#notify_delete";
 	notify_retract = "pubsub#notify_retract";
+	include_payload = "pubsub#deliver_payloads";
 };
 local reverse_config_field_map = {};
 for k, v in pairs(config_field_map) do reverse_config_field_map[v] = k; end
@@ -189,6 +195,7 @@
 		["pubsub#deliver_notifications"] = node_config["notify_items"];
 		["pubsub#notify_delete"] = node_config["notify_delete"];
 		["pubsub#notify_retract"] = node_config["notify_retract"];
+		["pubsub#deliver_payloads"] =  node_config["include_payload"]
 	}
 end