comparison mod_server_contact_info/mod_server_contact_info.lua @ 2318:3e5828e3f17f

mod_server_contact_info: Log error when no addresses or admins are set
author Kim Alvefur <zash@zash.se>
date Sat, 01 Oct 2016 17:15:03 +0200
parents 465b34fdeb60
children 86128b948fed
comparison
equal deleted inserted replaced
2317:465b34fdeb60 2318:3e5828e3f17f
12 security = true; 12 security = true;
13 support = true; 13 support = true;
14 } 14 }
15 15
16 local contact_config = module:get_option("contact_info"); 16 local contact_config = module:get_option("contact_info");
17 if not contact_config then -- we'll use admins from the config as default 17 if not contact_config or not next(contact_config) then -- we'll use admins from the config as default
18 local admins = module:get_option_inherited_set("admins", {}); 18 local admins = module:get_option_inherited_set("admins", {});
19 if admins:empty() then 19 if admins:empty() then
20 module:log("debug", "No contact_info or admins in config"); 20 module:log("error", "No contact_info or admins set in config");
21 return -- Nothing to attach, so we'll just skip it. 21 return -- Nothing to attach, so we'll just skip it.
22 end 22 end
23 module:log("debug", "No contact_info in config, using admins as fallback"); 23 module:log("debug", "No contact_info in config, using admins as fallback");
24 contact_config = { 24 contact_config = {
25 admin = array.collect( admins / function(admin) return "xmpp:" .. admin; end); 25 admin = array.collect( admins / function(admin) return "xmpp:" .. admin; end);
26 }; 26 };
27 end 27 end
28 if not next(contact_config) then 28
29 module:log("debug", "No contacts, skipping");
30 return -- No use in serving an empty form.
31 end
32 local form_layout = { 29 local form_layout = {
33 { value = "http://jabber.org/network/serverinfo"; type = "hidden"; name = "FORM_TYPE"; }; 30 { value = "http://jabber.org/network/serverinfo"; type = "hidden"; name = "FORM_TYPE"; };
34 }; 31 };
35 local form_values = {}; 32 local form_values = {};
36 33