A number of people are now running my patch to mod_cloud_notify that adds
"last-message-priority" for distinguishing events that should trigger a UI
alert vs silent background fetch. I know there's another approach with
"stripped stanzas" but I believe that it still leaks too much information
to the pubsub node, like whether or not someone is using OMEMO.



commit:
https://github.com/chrisballinger/prosody-modules/commit/40486273306f13ea68236745858df9b95a07c4fb
patch:
https://github.com/chrisballinger/prosody-modules/commit/40486273306f13ea68236745858df9b95a07c4fb.patch

-- 
You received this message because you are subscribed to the Google Groups 
"prosody-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/prosody-dev.
For more options, visit https://groups.google.com/d/optout.
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" 
})

Reply via email to