Changeset

1909:c7389fe74de7

mod_cloud_notify: Make inclusion of message sender and body optional via config option
author Kim Alvefur <zash@zash.se>
date Wed, 14 Oct 2015 14:07:57 +0200
parents 1908:eba279ddc050
children 1910:720b291cb340
files mod_cloud_notify/mod_cloud_notify.lua
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mod_cloud_notify/mod_cloud_notify.lua	Wed Oct 14 14:07:08 2015 +0200
+++ b/mod_cloud_notify/mod_cloud_notify.lua	Wed Oct 14 14:07:57 2015 +0200
@@ -9,6 +9,10 @@
 
 local xmlns_push = "urn:xmpp:push:0";
 
+-- configuration
+local include_body = module:get_option("push_notification_with_body", true);
+local include_sender = module:get_option("push_notification_with_sender", true);
+
 -- For keeping state across reloads
 local push_enabled = module:shared("push-enabled-users");
 
@@ -86,11 +90,16 @@
 		local push_publish = st.iq({ to = push_jid, from = module.host, type = "set", id = "push" })
 			:tag("pubsub", { xmlns = "http://jabber.org/protocol/pubsub" })
 				:tag("publish", { node = push_node });
-		push_publish:add_child(push_form:form({
+		local form_data = {
 			["message-count"] = tostring(push_info.count);
-			["last-message-sender"] = stanza.attr.from;
-			["last-message-body"] = stanza:get_child_text("body");
-		}));
+		};
+		if include_sender then
+			form_data["last-message-sender"] = stanza.attr.from;
+		end
+		if include_body then
+			form_data["last-message-body"] = stanza:get_child_text("body");
+		end
+		push_publish:add_child(push_form:form(form_data));
 		push_publish:up(); -- / publish
 		if push_info.options then
 			push_publish:tag("publish-options"):add_child(push_info.options);