Mercurial > prosody-modules
view mod_muc_gateway_optimize/mod_muc_gateway_optimize.lua @ 6261:1c62edeb9147
mod_pastebin: Update Readme
diff --git a/mod_pastebin/README.md b/mod_pastebin/README.md
--- a/mod_pastebin/README.md
+++ b/mod_pastebin/README.md
@@ -37,12 +37,14 @@ For example:
Pastes will be available by default at
`http://<your-prosody>:5280/pastebin/` by default.
-In Prosody 0.9 and later this can be changed with [HTTP
-settings](https://prosody.im/doc/http).
+Ports and path can be changed with [HTTP
+settings](https://prosody.im/doc/http), for example like:
-In 0.8 and older this can be changed with `pastebin_ports` (see below),
-or you can forward another external URL from your web server to Prosody,
-use `pastebin_url` to set that URL.
+``` {.lua}
+ http_paths = {
+ pastebin = "/$host-paste";
+ }
+```
# Discovery
@@ -82,27 +84,16 @@ The line and character tresholds are adv
pastebin_line_threshold The maximum number of lines a message may have before it is sent to the pastebin. (default 4 lines)
pastebin_trigger A string of characters (e.g. "!paste ") which if detected at the start of a message, always sends the message to the pastebin, regardless of length. (default: not set)
pastebin_expire_after Number of hours after which to expire (remove) a paste, defaults to 24. Set to 0 to store pastes permanently on disk.
- pastebin_ports List of ports to run the HTTP server on, same format as mod_httpserver's http_ports[^1]
- pastebin_url Base URL to display for pastebin links, must end with / and redirect to Prosody's built-in HTTP server[^2]
# Compatibility
- ------ -------
- trunk Works
+ ------ ---------------------
+ trunk Works as of 25-06-13
+ 13 Works
0.12 Works
- 0.11 Works
- 0.10 Works
- 0.9 Works
- 0.8 Works
- ------ -------
+ ------ ---------------------
# Todo
- Maximum paste length
- Web interface to submit pastes?
-
-[^1]: As of Prosody 0.9, `pastebin_ports` is replaced by `http_ports`,
- see [Prosody HTTP server documentation](https://prosody.im/doc/http)
-
-[^2]: See also
- [http_external_url](https://prosody.im/doc/http#external_url)
| author | Menel <menel@snikket.de> |
|---|---|
| date | Fri, 13 Jun 2025 11:39:58 +0200 |
| parents | 23c4c61a1068 |
| children |
line wrap: on
line source
local jid = require("util.jid") local mod_muc = module:depends("muc") local gateway_hosts = module:get_option_array("gateway_hosts", {}) function optimize(remote_host, event) local stanza = event.stanza module:log("debug", "optimize presence event destined for " .. remote_host) local muc_x = stanza:get_child("x", "http://jabber.org/protocol/muc#user") if muc_x then for status in muc_x:childtags("status") do if status.attr.status == "110" then module:log("debug", "optimize delivering 110") -- Always deliver self-presence return end end end local bare_jid = jid.bare(stanza.attr.to) local room = mod_muc.get_room_from_jid(jid.bare(stanza.attr.from)) if not room then return end for nick, occupant in room:each_occupant() do local occupant_host = jid.host(occupant.bare_jid) if occupant_host == remote_host then -- This is the "first" occupant from the host -- which is the only one we will route non-110 -- presence to if occupant.bare_jid == bare_jid then module:log("debug", "optimize found first occupant, so route") return else module:log("debug", "optimize found non-first occupant, so drop") return true end end end -- If we get here we found no occupants for this host module:log("debug", "optimize found no occupants for host " .. remote_host) end -- Note this will only affect gateways over s2s for now module:hook("route/remote", function (event) if event.stanza.name ~= "presence" then return end local remote_host = jid.host(event.stanza.attr.to) for _, gateway_host in pairs(gateway_hosts) do if remote_host == gateway_host then return optimize(remote_host, event) end end end, 1000)
