# HG changeset patch # User Kim Alvefur # Date 1475334837 -7200 # Node ID 465b34fdeb60f6395ee830827c50305bbf185977 # Parent 2a2de19413e7e594d97affb8791573ac9ce7b0a8 mod_server_contact_info: Include both global and local admins in fallback mode diff -r 2a2de19413e7 -r 465b34fdeb60 mod_server_contact_info/mod_server_contact_info.lua --- a/mod_server_contact_info/mod_server_contact_info.lua Sat Oct 01 01:09:31 2016 +0200 +++ b/mod_server_contact_info/mod_server_contact_info.lua Sat Oct 01 17:13:57 2016 +0200 @@ -1,5 +1,6 @@ -- This plugin implements http://xmpp.org/extensions/xep-0157.html 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 @@ -14,18 +15,15 @@ local contact_config = module:get_option("contact_info"); if not contact_config then -- we'll use admins from the config as default - contact_config = { admin = {}; }; - local admins = module:get_option("admins"); - if not admins or #admins == 0 then + local admins = module:get_option_inherited_set("admins", {}); + if admins:empty() then module:log("debug", "No contact_info or admins in config"); return -- Nothing to attach, so we'll just skip it. end module:log("debug", "No contact_info in config, using admins as fallback"); - --TODO fetch global admins too? - for i = 1,#admins do - t_insert(contact_config.admin, "xmpp:" .. admins[i]) - module:log("debug", "Added %s to admin-addresses", admins[i]); - end + contact_config = { + admin = array.collect( admins / function(admin) return "xmpp:" .. admin; end); + }; end if not next(contact_config) then module:log("debug", "No contacts, skipping");