mod_cloud_notify_encrypted: Truncate message body to 255 characters
authorMatthew Wild <mwild1@gmail.com>
Wed, 13 Jan 2021 14:19:20 +0000
changeset 4335 2e355540f8c8
parent 4334 e655581173be
child 4336 7a5ca4b285cb
mod_cloud_notify_encrypted: Truncate message body to 255 characters Total size limit is 3-4KB, and this should be enough for a small notification.
mod_cloud_notify_encrypted/mod_cloud_notify_encrypted.lua
--- a/mod_cloud_notify_encrypted/mod_cloud_notify_encrypted.lua	Wed Jan 13 14:18:24 2021 +0000
+++ b/mod_cloud_notify_encrypted/mod_cloud_notify_encrypted.lua	Wed Jan 13 14:19:20 2021 +0000
@@ -56,6 +56,10 @@
 	local push_summary = event.push_summary;
 
 	local original_stanza = event.original_stanza;
+	local body = original_stanza:get_child_text("body");
+	if #body > 255 then
+		body = body:sub(1, 255);
+	end
 
 	local push_payload = {
 		unread = tonumber(push_summary["message-count"]) or 1;