Mercurial > prosody-modules
annotate mod_stanza_counter/mod_stanza_counter_http.lua @ 6258: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 |
| parents | 7dbde05b48a9 |
| children |
| rev | line source |
|---|---|
|
436
e4a1f0425380
mod_stanza_counter: splitted plugin :/
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
1 -- (C) 2011, Marco Cirillo (LW.Org) |
|
e4a1f0425380
mod_stanza_counter: splitted plugin :/
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
2 -- Exposes stats on HTTP for the stanza counter module. |
|
e4a1f0425380
mod_stanza_counter: splitted plugin :/
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
3 |
|
650
34e7093cf419
mod_stanza_counter_http: updated to current HTTP API.
Marco Cirillo <maranda@lightwitch.org>
parents:
608
diff
changeset
|
4 module:depends("http") |
|
436
e4a1f0425380
mod_stanza_counter: splitted plugin :/
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
5 |
|
678
429be98872dc
mod_stanza_counter_http: change the skipped get_option_array to get_option_string it was supposed to.
Marco Cirillo <maranda@lightwitch.org>
parents:
659
diff
changeset
|
6 local base_path = module:get_option_string("stanza_counter_basepath", "/stanza-counter/") |
|
436
e4a1f0425380
mod_stanza_counter: splitted plugin :/
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
7 |
|
e4a1f0425380
mod_stanza_counter: splitted plugin :/
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
8 -- http handlers |
|
e4a1f0425380
mod_stanza_counter: splitted plugin :/
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
9 |
|
e4a1f0425380
mod_stanza_counter: splitted plugin :/
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
10 local r_200 = "\n<html>\n<head>\n<title>Prosody's Stanza Counter</title>\n<meta name=\"robots\" content=\"noindex, nofollow\" />\n</head>\n\n<body>\n<h3>Incoming and Outgoing stanzas divided per type</h3>\n<p><strong>Incoming IQs</strong>: %d<br/>\n<strong>Outgoing IQs</strong>: %d<br/>\n<strong>Incoming Messages</strong>: %d<br/>\n<strong>Outgoing Messages</strong>: %d<br/>\n<strong>Incoming Presences</strong>: %d<br/>\n<strong>Outgoing Presences</strong>: %d<p>\n</body>\n\n</html>\n" |
|
e4a1f0425380
mod_stanza_counter: splitted plugin :/
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
11 |
|
e4a1f0425380
mod_stanza_counter: splitted plugin :/
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
12 local r_err = "\n<html>\n<head>\n<title>Prosody's Stanza Counter - Error %s</title>\n<meta name=\"robots\" content=\"noindex, nofollow\" />\n</head>\n\n<body>\n<h3>%s</h3>\n</body>\n\n</html>\n" |
|
e4a1f0425380
mod_stanza_counter: splitted plugin :/
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
13 |
|
650
34e7093cf419
mod_stanza_counter_http: updated to current HTTP API.
Marco Cirillo <maranda@lightwitch.org>
parents:
608
diff
changeset
|
14 local function res(event, code, body, extras) |
|
34e7093cf419
mod_stanza_counter_http: updated to current HTTP API.
Marco Cirillo <maranda@lightwitch.org>
parents:
608
diff
changeset
|
15 local response = event.response |
|
1343
7dbde05b48a9
all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
678
diff
changeset
|
16 |
|
650
34e7093cf419
mod_stanza_counter_http: updated to current HTTP API.
Marco Cirillo <maranda@lightwitch.org>
parents:
608
diff
changeset
|
17 if extras then |
|
34e7093cf419
mod_stanza_counter_http: updated to current HTTP API.
Marco Cirillo <maranda@lightwitch.org>
parents:
608
diff
changeset
|
18 for header, data in pairs(extras) do response.headers[header] = data end |
|
34e7093cf419
mod_stanza_counter_http: updated to current HTTP API.
Marco Cirillo <maranda@lightwitch.org>
parents:
608
diff
changeset
|
19 end |
|
34e7093cf419
mod_stanza_counter_http: updated to current HTTP API.
Marco Cirillo <maranda@lightwitch.org>
parents:
608
diff
changeset
|
20 |
|
34e7093cf419
mod_stanza_counter_http: updated to current HTTP API.
Marco Cirillo <maranda@lightwitch.org>
parents:
608
diff
changeset
|
21 response.status_code = code |
|
34e7093cf419
mod_stanza_counter_http: updated to current HTTP API.
Marco Cirillo <maranda@lightwitch.org>
parents:
608
diff
changeset
|
22 response:send(body) |
|
436
e4a1f0425380
mod_stanza_counter: splitted plugin :/
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
23 end |
|
e4a1f0425380
mod_stanza_counter: splitted plugin :/
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
24 |
|
650
34e7093cf419
mod_stanza_counter_http: updated to current HTTP API.
Marco Cirillo <maranda@lightwitch.org>
parents:
608
diff
changeset
|
25 local function req(event) |
|
436
e4a1f0425380
mod_stanza_counter: splitted plugin :/
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
26 if not prosody.stanza_counter then |
|
650
34e7093cf419
mod_stanza_counter_http: updated to current HTTP API.
Marco Cirillo <maranda@lightwitch.org>
parents:
608
diff
changeset
|
27 local err500 = r_err:format(event, 500, "Stats not found, is the counter module loaded?") |
|
437
78a2a6b2bea3
mod_stanza_counter: missing end.
Marco Cirillo <maranda@lightwitch.org>
parents:
436
diff
changeset
|
28 return res(500, err500) end |
|
436
e4a1f0425380
mod_stanza_counter: splitted plugin :/
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
29 if method == "GET" then |
|
e4a1f0425380
mod_stanza_counter: splitted plugin :/
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
30 local forge_res = r_200:format(prosody.stanza_counter.iq["incoming"], |
|
e4a1f0425380
mod_stanza_counter: splitted plugin :/
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
31 prosody.stanza_counter.iq["outgoing"], |
|
e4a1f0425380
mod_stanza_counter: splitted plugin :/
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
32 prosody.stanza_counter.message["incoming"], |
|
e4a1f0425380
mod_stanza_counter: splitted plugin :/
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
33 prosody.stanza_counter.message["outgoing"], |
|
e4a1f0425380
mod_stanza_counter: splitted plugin :/
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
34 prosody.stanza_counter.presence["incoming"], |
|
535
39c7115be370
mod_stanza_counter_http: replaced prosody.events.add_handler with module:hook.
Marco Cirillo <maranda@lightwitch.org>
parents:
518
diff
changeset
|
35 prosody.stanza_counter.presence["outgoing"]) |
|
650
34e7093cf419
mod_stanza_counter_http: updated to current HTTP API.
Marco Cirillo <maranda@lightwitch.org>
parents:
608
diff
changeset
|
36 return res(event, 200, forge_res) |
|
436
e4a1f0425380
mod_stanza_counter: splitted plugin :/
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
37 else |
|
650
34e7093cf419
mod_stanza_counter_http: updated to current HTTP API.
Marco Cirillo <maranda@lightwitch.org>
parents:
608
diff
changeset
|
38 local err405 = r_err:format(405, "Only GET is supported") |
|
34e7093cf419
mod_stanza_counter_http: updated to current HTTP API.
Marco Cirillo <maranda@lightwitch.org>
parents:
608
diff
changeset
|
39 return res(event, 405, err405, {["Allow"] = "GET"}) |
|
436
e4a1f0425380
mod_stanza_counter: splitted plugin :/
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
40 end |
|
e4a1f0425380
mod_stanza_counter: splitted plugin :/
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
41 end |
|
e4a1f0425380
mod_stanza_counter: splitted plugin :/
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
42 |
|
e4a1f0425380
mod_stanza_counter: splitted plugin :/
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
43 -- initialization. |
|
562
b3f8435e661c
mod_stanza_counter_http: added cleanup function (from mod_register_json)
Marco Cirillo <maranda@lightwitch.org>
parents:
535
diff
changeset
|
44 |
|
650
34e7093cf419
mod_stanza_counter_http: updated to current HTTP API.
Marco Cirillo <maranda@lightwitch.org>
parents:
608
diff
changeset
|
45 module:provides("http", { |
|
34e7093cf419
mod_stanza_counter_http: updated to current HTTP API.
Marco Cirillo <maranda@lightwitch.org>
parents:
608
diff
changeset
|
46 default_path = base_path, |
|
34e7093cf419
mod_stanza_counter_http: updated to current HTTP API.
Marco Cirillo <maranda@lightwitch.org>
parents:
608
diff
changeset
|
47 route = { |
|
34e7093cf419
mod_stanza_counter_http: updated to current HTTP API.
Marco Cirillo <maranda@lightwitch.org>
parents:
608
diff
changeset
|
48 ["GET /"] = req, |
|
34e7093cf419
mod_stanza_counter_http: updated to current HTTP API.
Marco Cirillo <maranda@lightwitch.org>
parents:
608
diff
changeset
|
49 ["POST /"] = req |
|
34e7093cf419
mod_stanza_counter_http: updated to current HTTP API.
Marco Cirillo <maranda@lightwitch.org>
parents:
608
diff
changeset
|
50 } |
|
34e7093cf419
mod_stanza_counter_http: updated to current HTTP API.
Marco Cirillo <maranda@lightwitch.org>
parents:
608
diff
changeset
|
51 }) |
