Mercurial > prosody-modules
annotate mod_muc_intercom/mod_muc_intercom.lua @ 6082:1a6cd0bbb7ab
mod_compliance_2023: Add 2023 Version of the compliance module, basis is the 2021 Version.
diff --git a/mod_compliance_2023/README.md b/mod_compliance_2023/README.md
new file mode 100644
--- /dev/null
+++ b/mod_compliance_2023/README.md
@@ -0,0 +1,22 @@
+---
+summary: XMPP Compliance Suites 2023 self-test
+labels:
+- Stage-Beta
+rockspec:
+ dependencies:
+ - mod_cloud_notify
+
+...
+
+Compare the list of enabled modules with
+[XEP-0479: XMPP Compliance Suites 2023] and produce basic report to the
+Prosody log file.
+
+If installed with the Prosody plugin installer then all modules needed for a green checkmark should be included. (With prosody 0.12 only [mod_cloud_notify] is not included with prosody and we need the community module)
+
+# Compatibility
+
+ Prosody-Version Status
+ --------------- ----------------------
+ trunk Works as of 2024-12-21
+ 0.12 Works
diff --git a/mod_compliance_2023/mod_compliance_2023.lua b/mod_compliance_2023/mod_compliance_2023.lua
new file mode 100644
--- /dev/null
+++ b/mod_compliance_2023/mod_compliance_2023.lua
@@ -0,0 +1,79 @@
+-- Copyright (c) 2021 Kim Alvefur
+--
+-- This module is MIT licensed.
+
+local hostmanager = require "core.hostmanager";
+
+local array = require "util.array";
+local set = require "util.set";
+
+local modules_enabled = module:get_option_inherited_set("modules_enabled");
+
+for host in pairs(hostmanager.get_children(module.host)) do
+ local component = module:context(host):get_option_string("component_module");
+ if component then
+ modules_enabled:add(component);
+ modules_enabled:include(module:context(host):get_option_set("modules_enabled", {}));
+ end
+end
+
+local function check(suggested, alternate, ...)
+ if set.intersection(modules_enabled, set.new({suggested; alternate; ...})):empty() then return suggested; end
+ return false;
+end
+
+local compliance = {
+ array {"Server"; check("tls"); check("disco")};
+
+ array {"Advanced Server"; check("pep", "pep_simple")};
+
+ array {"Web"; check("bosh"); check("websocket")};
+
+ -- No Server requirements for Advanced Web
+
+ array {"IM"; check("vcard_legacy", "vcard"); check("carbons"); check("http_file_share", "http_upload")};
+
+ array {
+ "Advanced IM";
+ check("vcard_legacy", "vcard");
+ check("blocklist");
+ check("muc");
+ check("private");
+ check("smacks");
+ check("mam");
+ check("bookmarks");
+ };
+
+ array {"Mobile"; check("smacks"); check("csi_simple", "csi_battery_saver")};
+
+ array {"Advanced Mobile"; check("cloud_notify")};
+
+ array {"A/V Calling"; check("turn_external", "external_services", "turncredentials", "extdisco")};
+
+};
+
+function check_compliance()
+ local compliant = true;
+ for _, suite in ipairs(compliance) do
+ local section = suite:pop(1);
+ if module:get_option_boolean("compliance_" .. section:lower():gsub("%A", "_"), true) then
+ local missing = set.new(suite:filter(function(m) return type(m) == "string" end):map(function(m) return "mod_" .. m end));
+ if suite[1] then
+ if compliant then
+ compliant = false;
+ module:log("warn", "Missing some modules for XMPP Compliance 2023");
+ end
+ module:log("info", "%s Compliance: %s", section, missing);
+ end
+ end
+ end
+
+ if compliant then module:log("info", "XMPP Compliance 2023: Compliant ✔️"); end
+end
+
+if prosody.start_time then
+ check_compliance()
+else
+ module:hook_global("server-started", check_compliance);
+end
+
| author | Menel <menel@snikket.de> |
|---|---|
| date | Sun, 22 Dec 2024 16:06:28 +0100 |
| parents | c271bfa3d625 |
| children |
| rev | line source |
|---|---|
|
247
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 -- Relay messages between rooms |
|
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 -- By Kim Alvefur <zash@zash.se> |
|
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 |
|
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 local host_session = prosody.hosts[module.host]; |
|
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 local st_msg = require "util.stanza".message; |
|
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 local jid = require "util.jid"; |
|
285
108ac6f16d2d
mod_muc_intercom: Add a delay to the forwarded message.
Kim Alvefur <zash@zash.se>
parents:
280
diff
changeset
|
7 local now = require "util.datetime".datetime; |
|
247
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 |
|
3070
c271bfa3d625
mod_muc_intercom: Fix to use correct name for variable
Kim Alvefur <zash@zash.se>
parents:
2809
diff
changeset
|
9 local function get_room_from_jid(mod_muc, jid) |
|
c271bfa3d625
mod_muc_intercom: Fix to use correct name for variable
Kim Alvefur <zash@zash.se>
parents:
2809
diff
changeset
|
10 if mod_muc.get_room_from_jid then |
|
c271bfa3d625
mod_muc_intercom: Fix to use correct name for variable
Kim Alvefur <zash@zash.se>
parents:
2809
diff
changeset
|
11 return mod_muc.get_room_from_jid(jid); |
|
1425
9c894b56b4e4
mod_muc_intercom: Make compatible with new MUC API.
Waqas Hussain <waqas20@gmail.com>
parents:
285
diff
changeset
|
12 elseif mod_muc.rooms then |
|
9c894b56b4e4
mod_muc_intercom: Make compatible with new MUC API.
Waqas Hussain <waqas20@gmail.com>
parents:
285
diff
changeset
|
13 return mod_muc.rooms[jid]; -- COMPAT 0.9, 0.10 |
|
9c894b56b4e4
mod_muc_intercom: Make compatible with new MUC API.
Waqas Hussain <waqas20@gmail.com>
parents:
285
diff
changeset
|
14 end |
|
9c894b56b4e4
mod_muc_intercom: Make compatible with new MUC API.
Waqas Hussain <waqas20@gmail.com>
parents:
285
diff
changeset
|
15 end |
|
9c894b56b4e4
mod_muc_intercom: Make compatible with new MUC API.
Waqas Hussain <waqas20@gmail.com>
parents:
285
diff
changeset
|
16 |
|
247
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 function check_message(data) |
|
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 local origin, stanza = data.origin, data.stanza; |
|
1425
9c894b56b4e4
mod_muc_intercom: Make compatible with new MUC API.
Waqas Hussain <waqas20@gmail.com>
parents:
285
diff
changeset
|
19 local mod_muc = host_session.muc; |
|
9c894b56b4e4
mod_muc_intercom: Make compatible with new MUC API.
Waqas Hussain <waqas20@gmail.com>
parents:
285
diff
changeset
|
20 if not mod_muc then return; end |
|
247
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 |
|
3070
c271bfa3d625
mod_muc_intercom: Fix to use correct name for variable
Kim Alvefur <zash@zash.se>
parents:
2809
diff
changeset
|
22 local this_room = get_room_from_jid(mod_muc, stanza.attr.to); |
|
247
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 if not this_room then return; end -- no such room |
|
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 |
|
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
25 local from_room_jid = this_room._jid_nick[stanza.attr.from]; |
|
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
26 if not from_room_jid then return; end -- no such nick |
|
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
27 |
|
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
28 local from_room, from_host, from_nick = jid.split(from_room_jid); |
|
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
29 |
|
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
30 local body = stanza:get_child("body"); |
|
253
7410d1005fea
mod_muc_intercom: Fix traceback on topic changes
Kim Alvefur <zash@zash.se>
parents:
247
diff
changeset
|
31 if not body then return; end -- No body, like topic changes |
|
247
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
32 body = body and body:get_text(); -- I feel like I want to do `or ""` there :/ |
|
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
33 local target_room, message = body:match("^@([^:]+):(.*)"); |
|
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
34 if not target_room or not message then return; end |
|
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
35 |
|
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
36 if target_room == from_room then return; end -- don't route to itself |
|
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
37 module:log("debug", "target room is %s", target_room); |
|
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
38 |
|
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
39 local bare_room = jid.join(target_room, from_host); |
|
3070
c271bfa3d625
mod_muc_intercom: Fix to use correct name for variable
Kim Alvefur <zash@zash.se>
parents:
2809
diff
changeset
|
40 local dest_room = get_room_from_jid(mod_muc, bare_room); |
|
1425
9c894b56b4e4
mod_muc_intercom: Make compatible with new MUC API.
Waqas Hussain <waqas20@gmail.com>
parents:
285
diff
changeset
|
41 if not dest_room then return; end -- TODO send a error |
|
247
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
42 module:log("info", "message from %s in %s to %s", from_nick, from_room, target_room); |
|
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
43 |
|
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
44 local sender = jid.join(target_room, module.host, from_room .. "/" .. from_nick); |
|
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
45 local forward_stanza = st_msg({from = sender, to = bare_room, type = "groupchat"}, message); |
|
285
108ac6f16d2d
mod_muc_intercom: Add a delay to the forwarded message.
Kim Alvefur <zash@zash.se>
parents:
280
diff
changeset
|
46 forward_stanza:tag("delay", { xmlns = 'urn:xmpp:delay', from = from_room_jid, stamp = now() }):up(); |
|
247
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
47 |
|
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
48 module:log("debug", "broadcasting message to target room"); |
|
1425
9c894b56b4e4
mod_muc_intercom: Make compatible with new MUC API.
Waqas Hussain <waqas20@gmail.com>
parents:
285
diff
changeset
|
49 dest_room:broadcast_message(forward_stanza); |
|
247
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
50 end |
|
fbddb9db1c82
adds mod_muc_intercom; forwards messages between rooms on a muc host
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
51 |
|
2809
6d3935226ffb
Backed out changeset 6d72c5172c74
Kim Alvefur <zash@zash.se>
parents:
1425
diff
changeset
|
52 module:hook("message/bare", check_message); |
