Software / code / prosody-modules
File
mod_pubsub_text_interface/mod_pubsub_text_interface.lua @ 6302:06fbbd45ba75
mod_cloud_notify: Readme: fix links and labels that were removed in the last commit
diff --git a/mod_cloud_notify/README.md b/mod_cloud_notify/README.md
--- a/mod_cloud_notify/README.md
+++ b/mod_cloud_notify/README.md
@@ -1,3 +1,9 @@
+----
+-labels:
+-- 'Stage-Beta'
+-summary: 'XEP-0357: Cloud push notifications'
+----
+
# Introduction
This module enables support for sending "push notifications" to clients
@@ -32,15 +38,15 @@ notification to your device. When your d
it will display it or wake up the app so it can connect to XMPP and
receive any pending messages.
-This protocol is described for developers in \[XEP-0357: Push
-Notifications\].
+This protocol is described for developers in [XEP-0357: Push
+Notifications].
-For this module to work reliably, you must have \[mod_smacks\],
-\[mod_mam\] and \[mod_carbons\] also enabled on your server.
+For this module to work reliably, you must have [mod_smacks],
+[mod_mam] and [mod_carbons] also enabled on your server.
Some clients, notably Siskin and Snikket iOS need some additional
extensions that are not currently defined in a standard XEP. To support
-these clients, see \[mod_cloud_notify_extensions\].
+these clients, see [mod_cloud_notify_extensions].
# Configuration
@@ -58,18 +64,18 @@ these clients, see \[mod_cloud_notify_ex
# Internal design notes
App servers are notified about offline messages, messages stored by
-\[mod_mam\] or messages waiting in the smacks queue. The business rules
+[mod_mam] or messages waiting in the smacks queue. The business rules
outlined
[here](//mail.jabber.org/pipermail/standards/2016-February/030925.html)
are all honored[^2].
-To cooperate with \[mod_smacks\] this module consumes some events:
+To cooperate with [mod_smacks] this module consumes some events:
`smacks-ack-delayed`, `smacks-hibernation-start` and
`smacks-hibernation-end`. These events allow this module to send out
notifications for messages received while the session is hibernated by
-\[mod_smacks\] or even when smacks acknowledgements for messages are
+[mod_smacks] or even when smacks acknowledgements for messages are
delayed by a certain amount of seconds configurable with the
-\[mod_smacks\] setting `smacks_max_ack_delay`.
+[mod_smacks] setting `smacks_max_ack_delay`.
The `smacks_max_ack_delay` setting allows to send out notifications to
clients which aren't already in smacks hibernation state (because the
| author | Menel <menel@snikket.de> |
|---|---|
| date | Fri, 13 Jun 2025 10:44:37 +0200 |
| parent | 5134:e0d0ef564095 |
line wrap: on
line source
local st = require "util.stanza"; local jid = require "util.jid"; local id = require "util.id"; local pubsub = module:depends "pubsub".service; local xmlns_quick_resp = "urn:xmpp:tmp:quick-response"; local name = module:get_option_string("name", "PubSub Service on "..module.host); local help = name..[[ Commands: - `help` - this help message - `list` - list available nodes - `subscriptions` - list nodes you are subscribed to - `subscribe NODE` - subscribe to a node - `unsubscribe NODE` - unsubscribe from a node]]; if pubsub.get_last_item then -- COMPAT not available in 0.10 help = help .. "\n- `last NODE` - send the last item (again)" end -- FIXME better word for "node" local friendly_pubsub_errors = { ["forbidden"] = "You are not allowed to do that"; ["item-not-found"] = "That node does not exist"; ["internal-server-error"] = "Something went wrong (see server logs)"; ["not-subscribed"] = "You were not subscribed"; }; module:hook("message/host", function (event) local stanza = event.stanza; local body = stanza:get_child_text("body"); if not body then return end -- bail out local from = stanza.attr.from; local reply = st.reply(stanza); reply.attr.id = id.medium(); local command, node_arg = body:match("^(%a+)%s+(.*)"); command = (command or body):lower(); if command == "help" then reply:body(help):up(); reply:tag("response", { xmlns = xmlns_quick_resp, value = "list", }):up(); reply:tag("response", { xmlns = xmlns_quick_resp, value = "subscriptions", }):up(); elseif command == "list" then local ok, nodes = pubsub:get_nodes(from); if ok then local list = {}; for node, node_obj in pairs(nodes) do table.insert(list, ("- `%s` %s"):format(node, node_obj.config.title or "")); end reply:body(table.concat(list, "\n")); else reply:body(friendly_pubsub_errors[nodes] or nodes); end elseif command == "subscriptions" then local ok, subs = pubsub:get_subscriptions(nil, from, from); if not ok then reply:body(friendly_pubsub_errors[subs] or subs); elseif #subs == 0 then reply:body("You are not subscribed to anything from this pubsub service"); else local response = {}; for i = 1, #subs do response[i] = string.format("- `%s`", subs[i].node); reply:tag("response", { xmlns = xmlns_quick_resp, value = "unsubscribe "..subs[i].node, }):up(); reply:tag("response", { xmlns = xmlns_quick_resp, value = "last "..subs[i].node, }):up(); end reply:body(table.concat(response, "\n")); end elseif command == "subscribe" then local ok, err = pubsub:add_subscription(node_arg, from, jid.bare(from), { ["pubsub#include_body"] = true }); reply:body(ok and "OK" or friendly_pubsub_errors[err] or err); elseif command == "unsubscribe" then local ok, err = pubsub:remove_subscription(node_arg, from, jid.bare(from)); reply:body(ok and "OK" or friendly_pubsub_errors[err] or err); elseif command == "last" and pubsub.get_last_item then local ok, item_id, item = pubsub:get_last_item(node_arg, from); if not ok then reply:body(friendly_pubsub_errors[item_id] or item_id); elseif not item_id then reply:body("That node does not contain any items"); else pubsub.config.broadcaster("items", node_arg, { [from] = { ["pubsub#include_body"] = true } }, item, nil, pubsub.nodes[node_arg]); reply:body("OK"); end else reply:body("Unknown command. `help` to list commands."):up(); reply:tag("response", { xmlns = xmlns_quick_resp, value = "help", }):up(); end reply:reset(); if stanza:get_child("no-copy", "urn:xmpp:hints") then reply:tag("no-copy", { xmlns = "urn:xmpp:hints" }):up(); end if stanza:get_child("no-store", "urn:xmpp:hints") then reply:tag("no-store", { xmlns = "urn:xmpp:hints" }):up(); end module:send(reply); return true; end);