Mercurial > prosody-modules
annotate mod_muc_webchat_url/mod_muc_webchat_url.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 | dcafddc31b1c |
| children |
| rev | line source |
|---|---|
|
3672
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
1 local jid_split = require "util.jid".split; |
|
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
2 module:depends"muc"; |
|
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
3 |
|
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
4 local webchat_baseurl = module:get_option_string("muc_webchat_baseurl", nil); |
|
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
5 |
|
3673
11ebf1da416b
mod_muc_webchat_url: Don't save templated value
Kim Alvefur <zash@zash.se>
parents:
3672
diff
changeset
|
6 local function get_default_url(room) |
|
3672
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
7 if not webchat_baseurl then |
|
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
8 -- no template |
|
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
9 return nil; |
|
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
10 end |
|
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
11 if room:get_hidden() or room:get_members_only() or room:get_password() then |
|
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
12 -- not a public room |
|
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
13 return nil; |
|
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
14 end |
|
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
15 return (webchat_baseurl:gsub("{(%w+)}", { |
|
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
16 jid = room.jid, |
|
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
17 node = select(1, jid_split(room.jid)), |
|
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
18 host = select(2, jid_split(room.jid)), |
|
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
19 })); |
|
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
20 end |
|
3069
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 |
|
3673
11ebf1da416b
mod_muc_webchat_url: Don't save templated value
Kim Alvefur <zash@zash.se>
parents:
3672
diff
changeset
|
22 local function get_webchat_url(room) |
|
11ebf1da416b
mod_muc_webchat_url: Don't save templated value
Kim Alvefur <zash@zash.se>
parents:
3672
diff
changeset
|
23 local webchat_url = room._data.webchat_url; |
|
11ebf1da416b
mod_muc_webchat_url: Don't save templated value
Kim Alvefur <zash@zash.se>
parents:
3672
diff
changeset
|
24 if webchat_url then -- explicitly configured |
|
11ebf1da416b
mod_muc_webchat_url: Don't save templated value
Kim Alvefur <zash@zash.se>
parents:
3672
diff
changeset
|
25 return webchat_url; |
|
11ebf1da416b
mod_muc_webchat_url: Don't save templated value
Kim Alvefur <zash@zash.se>
parents:
3672
diff
changeset
|
26 end |
|
3675
776ff0875e35
mod_muc_webchat_url: Fix default url
Kim Alvefur <zash@zash.se>
parents:
3673
diff
changeset
|
27 return get_default_url(room); |
|
3673
11ebf1da416b
mod_muc_webchat_url: Don't save templated value
Kim Alvefur <zash@zash.se>
parents:
3672
diff
changeset
|
28 end |
|
11ebf1da416b
mod_muc_webchat_url: Don't save templated value
Kim Alvefur <zash@zash.se>
parents:
3672
diff
changeset
|
29 |
|
3069
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
30 module:hook("muc-config-form", function(event) |
|
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
31 local room, form = event.room, event.form; |
|
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
32 table.insert(form, { |
|
3672
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
33 name = "muc#roomconfig_webchat_url", |
|
3069
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
34 type = "text-single", |
|
3672
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
35 label = "URL where this room can be joined", |
|
4725
dcafddc31b1c
mod_muc_webchat_url: Add hint of being an URL to form field
Kim Alvefur <zash@zash.se>
parents:
3675
diff
changeset
|
36 datatype = "xs:anyURI", |
|
3672
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
37 value = get_webchat_url(room), |
|
3069
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
38 }); |
|
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
39 end); |
|
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
40 |
|
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
41 module:hook("muc-config-submitted", function(event) |
|
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
42 local room, fields, changed = event.room, event.fields, event.changed; |
|
3672
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
43 local new = fields["muc#roomconfig_webchat_url"]; |
|
3673
11ebf1da416b
mod_muc_webchat_url: Don't save templated value
Kim Alvefur <zash@zash.se>
parents:
3672
diff
changeset
|
44 if new ~= get_webchat_url(room) then |
|
11ebf1da416b
mod_muc_webchat_url: Don't save templated value
Kim Alvefur <zash@zash.se>
parents:
3672
diff
changeset
|
45 if new == get_default_url(room) then |
|
11ebf1da416b
mod_muc_webchat_url: Don't save templated value
Kim Alvefur <zash@zash.se>
parents:
3672
diff
changeset
|
46 room._data.webchat_url = nil; |
|
11ebf1da416b
mod_muc_webchat_url: Don't save templated value
Kim Alvefur <zash@zash.se>
parents:
3672
diff
changeset
|
47 else |
|
11ebf1da416b
mod_muc_webchat_url: Don't save templated value
Kim Alvefur <zash@zash.se>
parents:
3672
diff
changeset
|
48 room._data.webchat_url = new; |
|
11ebf1da416b
mod_muc_webchat_url: Don't save templated value
Kim Alvefur <zash@zash.se>
parents:
3672
diff
changeset
|
49 end |
|
3069
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
50 if type(changed) == "table" then |
|
3672
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
51 changed["muc#roomconfig_webchat_url"] = true; |
|
3069
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
52 else |
|
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
53 event.changed = true; |
|
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
54 end |
|
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
55 end |
|
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
56 end); |
|
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
57 |
|
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
58 module:hook("muc-disco#info", function (event) |
|
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
59 local room, form, formdata = event.room, event.form, event.formdata; |
|
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
60 |
|
3672
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
61 local webchat_url = get_webchat_url(room); |
|
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
62 if not webchat_url or webchat_url == "" then |
|
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
63 return; |
|
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
64 end |
|
3069
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
65 table.insert(form, { |
|
3672
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
66 name = "muc#roominfo_webchat_url", |
|
3069
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
67 }); |
|
3672
b8bcea17ccd6
mod_muc_webchat_url: Advertise the URL to a webchat in disco#info
Kim Alvefur <zash@zash.se>
parents:
3546
diff
changeset
|
68 formdata["muc#roominfo_webchat_url"] = webchat_url; |
|
3069
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
69 end); |
|
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
70 |
