changeset 4334:d90ce7dc3f88

mod_cloud_notify_priority_tag: New module to support Tigase's push priority indicator extension
author Matthew Wild <mwild1@gmail.com>
date Wed, 13 Jan 2021 15:02:27 +0000
parents 97f369745ec7
children e03dadd4f2d1
files mod_cloud_notify_priority_tag/README.md mod_cloud_notify_priority_tag/mod_cloud_notify_priority_tag.lua
diffstat 2 files changed, 38 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_cloud_notify_priority_tag/README.md	Wed Jan 13 15:02:27 2021 +0000
@@ -0,0 +1,23 @@
+---
+labels:
+- 'Stage-Alpha'
+summary: 'Support for encrypted payloads in push notifications'
+...
+
+Introduction
+============
+
+This module implements support for a Tigase XMPP extension, [Priority of notifications](https://xeps.tigase.net//docs/push-notifications/priority/).
+It is a custom extension to [XEP-0357: Push Notifications](https://xmpp.org/extensions/xep-0357.html).
+
+It is planned that this will evolve to a XEP in the near future.
+
+Details
+=======
+
+Add to modules_enabled, there are no configuration options.
+
+Compatibility
+=============
+
+Not tested, but hopefully works on 0.11.x and later.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_cloud_notify_priority_tag/mod_cloud_notify_priority_tag.lua	Wed Jan 13 15:02:27 2021 +0000
@@ -0,0 +1,15 @@
+local xmlns_push_priority = "tigase:push:priority:0";
+
+-- https://xeps.tigase.net//docs/push-notifications/encrypt/#41-discovering-support
+local function account_disco_info(event)
+	event.reply:tag("feature", {var=xmlns_push_priority}):up();
+end
+module:hook("account-disco-info", account_disco_info);
+
+function handle_push(event)
+	if event.important then
+		event.notification_payload:text_tag("priority", "high", { xmlns = xmlns_push_priority });
+	end
+end
+
+module:hook("cloud_notify/push", handle_push);