Software /
code /
prosody-modules
Annotate
mod_idlecompat/mod_idlecompat.lua @ 4930:13070c6a7ce8
mod_http_muc_log: Fix exception on lack of trailing slash in room path
A request to /room leads to the match call returning nil which in turn
calls nodeprep(nil). In Prosody 0.11.x this does nothing and simply
returns the nil, while in 0.12 it is an error.
Now it redirects to the calendar view at /room/ - even for non-existant
rooms.
Discovered at a deployment with http_paths = { muc_log = "/" } and
requests to /robots.txt and similar, which now result in a uses redirect
before returning 404.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 22 Apr 2022 14:29:32 +0200 |
parent | 2164:4b58e35a72e0 |
rev | line source |
---|---|
1260
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
1 -- Last User Interaction in Presence via Last Activity compatibility module |
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
2 -- http://xmpp.org/extensions/xep-0319.html |
2164
4b58e35a72e0
mod_idlecompat: Reference the correct XEP (256, not 12) and drop a redundant check
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
1260
diff
changeset
|
3 -- http://xmpp.org/extensions/xep-0256.html |
1260
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
4 -- Copyright (C) 2014 Tobias Markmann |
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
5 -- |
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
6 -- This file is MIT/X11 licensed. |
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
7 |
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
8 local st = require "util.stanza"; |
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
9 local datetime = require "util.datetime"; |
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
10 |
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
11 local function on_presence(event) |
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
12 local stanza = event.stanza; |
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
13 |
2164
4b58e35a72e0
mod_idlecompat: Reference the correct XEP (256, not 12) and drop a redundant check
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
1260
diff
changeset
|
14 local last_activity = stanza:get_child("query", "jabber:iq:last"); |
1260
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
15 local has_idle = stanza:get_child("idle", "urn:xmpp:idle:1"); |
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
16 if last_activity and not has_idle then |
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
17 module:log("debug", "Adding XEP-0319 tag from Last Activity."); |
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
18 local seconds = last_activity.attr.seconds; |
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
19 local last_userinteraction = datetime.datetime(os.time() - seconds); |
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
20 stanza:tag("idle", { xmlns = "urn:xmpp:idle:1", since = last_userinteraction }):up(); |
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
21 end |
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
22 end |
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
23 |
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
24 -- incoming |
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
25 module:hook("presence/full", on_presence, 900); |
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
26 module:hook("presence/bare", on_presence, 900); |
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
27 |
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
28 -- outgoing |
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
29 module:hook("pre-presence/bare", on_presence, 900); |
4e14ad802d58
mod_idlecompat: Add initial version.
Tobias Markmann <tm@ayena.de>
parents:
diff
changeset
|
30 module:hook("pre-presence/full", on_presence, 900); |
2164
4b58e35a72e0
mod_idlecompat: Reference the correct XEP (256, not 12) and drop a redundant check
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
1260
diff
changeset
|
31 module:hook("pre-presence/host", on_presence, 900); |