Skip to content

Commit

Permalink
XEP-0357: Add last-message-priority support to distinguish messages w…
Browse files Browse the repository at this point in the history
…ith body
  • Loading branch information
chrisballinger committed Oct 17, 2017
1 parent 701d007 commit 4048627
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mod_cloud_notify/mod_cloud_notify.lua
Expand Up @@ -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);
Expand Down Expand Up @@ -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" })
Expand Down

0 comments on commit 4048627

Please sign in to comment.