Comparison

mod_server_contact_info/mod_server_contact_info.lua @ 6211:750d64c47ec6 draft

Merge
author Trần H. Trung <xmpp:trần.h.trung@trung.fun>
date Tue, 18 Mar 2025 00:31:36 +0700
parent 5948:254a21a104aa
comparison
equal deleted inserted replaced
6210:24316a399978 6211:750d64c47ec6
1 -- XEP-0157: Contact Addresses for XMPP Services for Prosody
2 --
3 -- Copyright (C) 2011-2018 Kim Alvefur
4 --
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
7 --
8
9 -- This module is backported from Prosody trunk for the benefit of
10 -- Prosody 0.12 deployments. The following line will ensure that it won't be
11 -- loaded in Prosody versions with built-in support for mod_server_info -
12 -- thus preferring the mod_server_contact_info shipped with Prosody instead.
13 --% conflicts: mod_server_info
14
15
16 local array = require "util.array";
17 local it = require "util.iterators";
18 local jid = require "util.jid";
19 local url = require "socket.url";
20
21 module:depends("server_info");
22
23 -- Source: http://xmpp.org/registrar/formtypes.html#http:--jabber.org-network-serverinfo
24 local address_types = {
25 abuse = "abuse-addresses";
26 admin = "admin-addresses";
27 feedback = "feedback-addresses";
28 sales = "sales-addresses";
29 security = "security-addresses";
30 status = "status-addresses";
31 support = "support-addresses";
32 };
33
34 -- JIDs of configured service admins are used as fallback
35 local admins = module:get_option_inherited_set("admins", {});
36
37 local contact_config = module:get_option("contact_info", {
38 admin = array.collect(admins / jid.prep / function(admin) return url.build({scheme = "xmpp"; path = admin}); end);
39 });
40
41 local fields = {};
42
43 for key, field_var in it.sorted_pairs(address_types) do
44 if contact_config[key] then
45 table.insert(fields, {
46 type = "list-multi";
47 name = key;
48 var = field_var;
49 value = contact_config[key];
50 });
51 end
52 end
53
54 module:add_item("server-info-fields", fields);