Mercurial > prosody-modules
annotate mod_swedishchef/mod_swedishchef.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 | d93a73282a93 |
| children |
| rev | line source |
|---|---|
|
22
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
1 -- Copyright (C) 2009 Florian Zeitz |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
2 -- Copyright (C) 2009 Matthew Wild |
|
1343
7dbde05b48a9
all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
985
diff
changeset
|
3 -- |
|
22
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
4 -- This project is MIT/X11 licensed. Please see the |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
5 -- COPYING file in the source package for more information. |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
6 -- |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
7 |
|
985
93ef813dfd06
mod_swedishchef: Use newer config API
Kim Alvefur <zash@zash.se>
parents:
26
diff
changeset
|
8 local trigger_string = module:get_option_string("swedishchef_trigger"); |
|
26
1fb5b8c20004
mod_swedishchef: Added configurable trigger
Florian Zeitz <florob@babelmonkeys.de>
parents:
22
diff
changeset
|
9 trigger_string = (trigger_string and trigger_string .. " ") or ""; |
|
1fb5b8c20004
mod_swedishchef: Added configurable trigger
Florian Zeitz <florob@babelmonkeys.de>
parents:
22
diff
changeset
|
10 |
|
1343
7dbde05b48a9
all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
985
diff
changeset
|
11 local chef = { |
|
7dbde05b48a9
all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
985
diff
changeset
|
12 { th = "t" }, |
|
22
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
13 |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
14 { ow = "o"}, |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
15 {["([^%w])o"] = "%1oo", |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
16 O = "Oo"}, |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
17 |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
18 {au = "oo", |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
19 u = "oo", U = "Oo"}, |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
20 {["([^o])o([^o])"] = "%1u%2"}, |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
21 {ir = "ur", |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
22 |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
23 an = "un", An = "Un", Au = "Oo"}, |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
24 |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
25 {e = "i", E = "I"}, |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
26 |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
27 { i = function () return select(math.random(2), "i", "ee"); end }, |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
28 |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
29 {a = "e", A = "E"}, |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
30 |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
31 {["e([^%w])"] = "e-a%1"}, |
|
1343
7dbde05b48a9
all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
985
diff
changeset
|
32 {f = "ff"}, |
|
22
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
33 |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
34 {v = "f", V = "F"}, |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
35 {w = "v", W = "V"} }; |
|
1343
7dbde05b48a9
all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
985
diff
changeset
|
36 |
|
22
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
37 function swedish(english) |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
38 local eng, url = english:match("(.*)(http://.*)$"); |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
39 if eng then english = eng; end |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
40 |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
41 for _,v in ipairs(chef) do |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
42 for k,v in pairs(v) do |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
43 english = english:gsub(k,v); |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
44 end |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
45 end |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
46 english = english:gsub("the", "zee"); |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
47 english = english:gsub("The", "Zee"); |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
48 english = english:gsub("tion", "shun"); |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
49 english = english:gsub("[.!?]$", "%1\nBork Bork Bork!"); |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
50 return tostring(english..((url and url) or "")); |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
51 end |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
52 |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
53 function check_message(data) |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
54 local origin, stanza = data.origin, data.stanza; |
|
1343
7dbde05b48a9
all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
985
diff
changeset
|
55 |
|
22
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
56 local body, bodyindex; |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
57 for k,v in ipairs(stanza) do |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
58 if v.name == "body" then |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
59 body, bodyindex = v, k; |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
60 end |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
61 end |
|
1343
7dbde05b48a9
all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
985
diff
changeset
|
62 |
|
22
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
63 if not body then return; end |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
64 body = body:get_text(); |
|
1343
7dbde05b48a9
all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
985
diff
changeset
|
65 |
|
26
1fb5b8c20004
mod_swedishchef: Added configurable trigger
Florian Zeitz <florob@babelmonkeys.de>
parents:
22
diff
changeset
|
66 if body and (body:find(trigger_string, 1, true) == 1) then |
|
2780
d93a73282a93
mod_swedishchef: Fix logging and traceback uncovered by util.format (thanks Kafkei)
Kim Alvefur <zash@zash.se>
parents:
2779
diff
changeset
|
67 module:log("debug", "Found trigger: %s", body:match(trigger_string, 1, true)); |
|
26
1fb5b8c20004
mod_swedishchef: Added configurable trigger
Florian Zeitz <florob@babelmonkeys.de>
parents:
22
diff
changeset
|
68 stanza[bodyindex][1] = swedish(body:gsub("^" .. trigger_string, "", 1)); |
|
22
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
69 end |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
70 end |
|
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
71 |
|
2778
2615facc461b
mod_swedishchef: Add configuration toggle
Matthew Wild <mwild1@gmail.com>
parents:
1343
diff
changeset
|
72 if module:get_option_boolean("swedish_chef_enabled", true) then |
|
2615facc461b
mod_swedishchef: Add configuration toggle
Matthew Wild <mwild1@gmail.com>
parents:
1343
diff
changeset
|
73 module:hook("message/bare", check_message); |
|
2615facc461b
mod_swedishchef: Add configuration toggle
Matthew Wild <mwild1@gmail.com>
parents:
1343
diff
changeset
|
74 end |
|
22
8d49732cf7dc
mod_swedishchef: Initial commit
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
75 |
|
2779
c53cc1ae4788
mod_swedishchef: Add event so other modules can use this filter
Matthew Wild <mwild1@gmail.com>
parents:
2778
diff
changeset
|
76 module:hook("swedish_chef/message_filter", check_message); |
