aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2017-09-23 13:35:33 +0100
committerMatthew Wild <mwild1@gmail.com>2017-09-23 13:35:33 +0100
commita865cd1175aca1a232b82b2bf7920fd88c987871 (patch)
tree0fa0687ea868a2c92212e04efd1f1e1a78e0931f
parent6424848fa3a36651925621531dc4ecc843eb88d2 (diff)
downloadprosody-a865cd1175aca1a232b82b2bf7920fd88c987871.tar.gz
prosody-a865cd1175aca1a232b82b2bf7920fd88c987871.zip
mod_server_contact_info: Import from prosody-modules 2c59f2f0c37d (fixes #778)
-rw-r--r--plugins/mod_server_contact_info.lua49
1 files changed, 49 insertions, 0 deletions
diff --git a/plugins/mod_server_contact_info.lua b/plugins/mod_server_contact_info.lua
new file mode 100644
index 00000000..7ee8a08f
--- /dev/null
+++ b/plugins/mod_server_contact_info.lua
@@ -0,0 +1,49 @@
+-- XEP-0157: Contact Addresses for XMPP Services for Prosody
+--
+-- Copyright (C) 2011-2016 Kim Alvefur
+--
+-- This file is MIT/X11 licensed.
+--
+
+local t_insert = table.insert;
+local array = require "util.array";
+local df_new = require "util.dataforms".new;
+
+-- Source: http://xmpp.org/registrar/formtypes.html#http:--jabber.org-network-serverinfo
+local valid_types = {
+ abuse = true;
+ admin = true;
+ feedback = true;
+ sales = true;
+ security = true;
+ support = true;
+}
+
+local contact_config = module:get_option("contact_info");
+if not contact_config or not next(contact_config) then -- we'll use admins from the config as default
+ local admins = module:get_option_inherited_set("admins", {});
+ if admins:empty() then
+ module:log("error", "No contact_info or admins set in config");
+ return -- Nothing to attach, so we'll just skip it.
+ end
+ module:log("info", "No contact_info in config, using admins as fallback");
+ contact_config = {
+ admin = array.collect( admins / function(admin) return "xmpp:" .. admin; end);
+ };
+end
+
+local form_layout = {
+ { value = "http://jabber.org/network/serverinfo"; type = "hidden"; name = "FORM_TYPE"; };
+};
+
+local form_values = {};
+
+for t in pairs(valid_types) do
+ local addresses = contact_config[t];
+ if addresses then
+ t_insert(form_layout, { name = t .. "-addresses", type = "list-multi" });
+ form_values[t .. "-addresses"] = addresses;
+ end
+end
+
+module:add_extension(df_new(form_layout):form(form_values, "result"));