Software / code / prosody-modules
File
mod_admin_message/mod_admin_message.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 | 2887:65082d91950e |
line wrap: on
line source
-- Prosody IM -- -- mod_admin_message -- Console-over-XMPP implementation. -- -- This module depends on Prosody's admin_telnet module -- -- Copyright (C) 2008-2010 Matthew Wild -- Copyright (C) 2008-2010 Waqas Hussain -- Copyright (C) 2012-2013 Mikael Berthe -- -- This project is MIT/X11 licensed. Please see the -- COPYING file in the source package for more information. -- local st = require "util.stanza"; local um_is_admin = require "core.usermanager".is_admin; local admin_telnet = module:depends("admin_telnet"); local telnet_def_env = module:shared("/*/admin_telnet/env"); local telnet_commands = module:shared("/*/admin_telnet/commands"); local default_env_mt = { __index = telnet_def_env }; local host = module.host; -- Create our own session. print() will store the results in a text -- string. send(), quit(), disconnect() are no-op. local function new_session () local session = { send = function () end; quit = function () end; disconnect = function () end; }; session.print = function (...) local t = {}; for i=1,select("#", ...) do t[i] = tostring(select(i, ...)); end local text = "| "..table.concat(t, "\t"); if session.fulltext then session.fulltext = session.fulltext .. "\n" .. text; else session.fulltext = text; end end session.env = setmetatable({}, default_env_mt); -- Load up environment with helper objects for name, t in pairs(telnet_def_env) do if type(t) == "table" then session.env[name] = setmetatable({ session = session }, { __index = t }); end end return session; end local function on_message(event) -- Check the type of the incoming stanza to avoid loops: if event.stanza.attr.type == "error" then return; -- We do not want to reply to these, so leave. end local userjid = event.stanza.attr.from; local bodytag = event.stanza:get_child("body"); local body = bodytag and bodytag:get_text() or ""; if not body or body == "" then -- We do not reply to empty messages (chatstates, etc.) return true; end -- Check the requester is an admin user if not um_is_admin(userjid, module.host) then module:log("info", "Ignored request from non-admin: %s", userjid); return; end -- Create a session in order to use an admin_telnet-like environment local session = new_session(); -- Process the message using admin_telnet's onincoming function admin_telnet.console:process_line(session, body.."\n"); -- Strip trailing blank line session.fulltext = tostring(session.fulltext):gsub("\n|%s*$", "") -- Send the reply stanza local reply_stanza = st.message({ from = host, to = userjid, type = "chat" }, session.fulltext); module:send(reply_stanza); return true; end local function on_presence(event) local send_presence = false; local userjid = event.stanza.attr.from; -- Check the requester is an admin user if not um_is_admin(userjid, module.host) then module:log("info", "Ignored presence from non-admin: %s", userjid); return; end if (event.stanza.attr.type == "subscribe") then module:log("info", "Subscription request from %s", userjid); send_presence = true; -- Send a subscription ack local presence_stanza = st.presence({ from = host, to = userjid, type = "subscribed", id = event.stanza.attr.id }); module:send(presence_stanza); elseif (event.stanza.attr.type == "probe") then send_presence = true; elseif (event.stanza.attr.type == "unsubscribe") then -- For information only... module:log("info", "Unsubscription request from %s", userjid); end if (send_presence == true) then -- Send a presence stanza module:send(st.presence({ from = host, to = userjid })); end return true; end module:hook("message/bare", on_message); module:hook("presence/bare", on_presence);