From 40486273306f13ea68236745858df9b95a07c4fb Mon Sep 17 00:00:00 2001 From: Chris Ballinger Date: Tue, 17 Oct 2017 15:39:41 -0700 Subject: [PATCH] XEP-0357: Add last-message-priority support to distinguish messages with body --- mod_cloud_notify/mod_cloud_notify.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mod_cloud_notify/mod_cloud_notify.lua b/mod_cloud_notify/mod_cloud_notify.lua index 2d02cbf..45135eb 100644 --- a/mod_cloud_notify/mod_cloud_notify.lua +++ b/mod_cloud_notify/mod_cloud_notify.lua @@ -14,6 +14,7 @@ local hashes = require"util.hashes"; local xmlns_push = "urn:xmpp:push:0"; -- configuration +local include_priority = module:get_option_boolean("push_notification_with_priority", true); local include_body = module:get_option_boolean("push_notification_with_body", false); local include_sender = module:get_option_boolean("push_notification_with_sender", false); local max_push_errors = module:get_option_number("push_max_errors", 50); @@ -270,6 +271,13 @@ local function handle_notify_request(stanza, node, user_push_services) if stanza and include_body then form_data["last-message-body"] = stanza:get_child_text("body"); end + if stanza and include_priority then + if stanza:get_child("body") or stanza:get_child("encrypted", "eu.siacs.conversations.axolotl") then + form_data["last-message-priority"] = "high" + else + form_data["last-message-priority"] = "low" + end + end push_publish:add_child(push_form:form(form_data)); if stanza and push_info.include_payload == "stripped" then push_publish:tag("payload", { type = "stripped" })