Mercurial > prosody-modules
view mod_muc_members_json/mod_muc_members_json.lua @ 6253:502963b86fbc
:multble modules: fix tab-> space
diff --git a/mod_admin_blocklist/README.md b/mod_admin_blocklist/README.md
--- a/mod_admin_blocklist/README.md
+++ b/mod_admin_blocklist/README.md
@@ -24,9 +24,9 @@ admin_blocklist_roles = { "prosody:opera
# Compatibility
Prosody-Version Status
- -------------- ------
- trunk* Works
- 13 Works
- 0.12 Works
+ ------------ ------
+ trunk* Works
+ 13 Works
+ 0.12 Works
*as of 2025-06-13
diff --git a/mod_csi_grace_period/README.md b/mod_csi_grace_period/README.md
--- a/mod_csi_grace_period/README.md
+++ b/mod_csi_grace_period/README.md
@@ -16,9 +16,9 @@ pocket is not the best use of radio time
Works with [mod_csi_simple][doc:modules:mod_csi_simple] which is
included with Prosody.
- ------- -------
- trunk* Works
- 13 Works
- 0.12 Works
+ ------- -------
+ trunk* Works
+ 13 Works
+ 0.12 Works
*as of 2025-06-13
diff --git a/mod_http_upload_external/README.md b/mod_http_upload_external/README.md
--- a/mod_http_upload_external/README.md
+++ b/mod_http_upload_external/README.md
@@ -87,10 +87,10 @@ Compatibility
=============
Prosody-Version Status
- ---------------- --------------------
- trunk Works as of 25-06-13
- 13 Works
- 0.12 Works
+ ---------------- --------------------
+ trunk Works as of 25-06-13
+ 13 Works
+ 0.12 Works
Implementation
==============
diff --git a/mod_muc_moderation/README.md b/mod_muc_moderation/README.md
--- a/mod_muc_moderation/README.md
+++ b/mod_muc_moderation/README.md
@@ -27,11 +27,10 @@ modules_enabled = {
# Compatibility
- ------- ---------------
- trunk Works^[as of 2025-06-13]
- 13 Works
- 0.12 Works
- ------- ---------------
+ ------- ---------------
+ trunk Works^[as of 2025-06-13]
+ 13 Works
+ 0.12 Works
## XEP version
diff --git a/mod_s2s_idle_timeout/README.md b/mod_s2s_idle_timeout/README.md
--- a/mod_s2s_idle_timeout/README.md
+++ b/mod_s2s_idle_timeout/README.md
@@ -25,10 +25,9 @@ Compatibility
=============
Prosody Version Status
- ----------------- -----------
- trunk[^1] Works
- 13 Works
- 0.12 Works
- ----------------- -----------
+ ----------------- -----------
+ trunk[^1] Works
+ 13 Works
+ 0.12 Works
[^1]: as of 2025-06-13
diff --git a/mod_s2s_keepalive/README.md b/mod_s2s_keepalive/README.md
--- a/mod_s2s_keepalive/README.md
+++ b/mod_s2s_keepalive/README.md
@@ -34,10 +34,9 @@ Compatibility
=============
Prosody Version Status
- ----------------- -----------
- trunk[^1] Works
- 13 Works
- 0.12 Works
- ----------------- -----------
+ ----------------- -----------
+ trunk[^1] Works
+ 13 Works
+ 0.12 Works
[^1]: as of 2025-06-13
| author | Menel <menel@snikket.de> |
|---|---|
| date | Fri, 13 Jun 2025 09:58:51 +0200 |
| parents | 80abda15a1e9 |
| children | 459cb2c2789b |
line wrap: on
line source
local http = require "net.http"; local json = require "util.json"; local json_url = assert(module:get_option_string("muc_members_json_url"), "muc_members_json_url required"); local managed_mucs = module:get_option("muc_members_json_mucs"); local mod_muc = module:depends("muc"); --[[ { xsf = { team_hats = { board = { id = "xmpp:xmpp.org/hats/board"; title = "Board"; }; }; member_hat = { id = "xmpp:xmpp.org/hats/member"; title = "XSF member"; }; }; iteam = { team_hats = { iteam = { id = "xmpp:xmpp.org/hats/iteam"; title = "Infra team"; }; }; }; } --]] local function get_hats(member_info, muc_config) local hats = {}; if muc_config.member_hat then hats[muc_config.member_hat.id] = { title = muc_config.member_hat.title; active = true; }; end if muc_config.team_hats and member_info.roles then for _, role in ipairs(member_info.roles) do local hat = muc_config.team_hats[role]; if hat then hats[hat.id] = { title = hat.title; active = true; }; end end end return hats; end function module.load() http.request(json_url) :next(function (result) return json.decode(result.body); end) :next(function (data) module:log("debug", "DATA: %s", require "util.serialization".serialize(data, "debug")); for name, muc_config in pairs(managed_mucs) do local muc_jid = name.."@"..module.host; local muc = mod_muc.get_room_from_jid(muc_jid); module:log("warn", "%s -> %s -> %s", name, muc_jid, muc); if muc then local jids = {}; for _, member_info in ipairs(data.members) do for _, member_jid in ipairs(member_info.jids) do jids[member_jid] = true; local affiliation = muc:get_affiliation(member_jid); if not affiliation then muc:set_affiliation(true, member_jid, "member", "imported membership"); muc:set_affiliation_data(member_jid, "source", module.name); end muc:set_affiliation_data(member_jid, "hats", get_hats(member_info, muc_config)); end end -- Remove affiliation from folk who weren't in the source data but previously were for jid, aff, data in muc:each_affiliation() do if not jids[jid] and data and data.source == module.name then muc:set_affiliation(true, jid, "none", "imported membership lost"); end end end end end):catch(function (err) module:log("error", "FAILED: %s", err); end); end
