comparison mod_adhoc_blacklist/mod_adhoc_blacklist.lua @ 1736:efbb73851af9

mod_adhoc_blacklist: Fix traceback if blacklist is empty
author Kim Alvefur <zash@zash.se>
date Sat, 16 May 2015 14:46:29 +0200
parents d82b03e79d8b
children
comparison
equal deleted inserted replaced
1735:c2d43b568178 1736:efbb73851af9
32 local blocklists = module:open_store("blocklist"); 32 local blocklists = module:open_store("blocklist");
33 33
34 local blocklist_handler = adhoc_inital_data(blocklist_form, function () 34 local blocklist_handler = adhoc_inital_data(blocklist_form, function ()
35 local blacklistjids = {}; 35 local blacklistjids = {};
36 local blacklist = blocklists:get(); 36 local blacklist = blocklists:get();
37 for jid in pairs(blacklist) do 37 if blacklist then
38 table.insert(blacklistjids, jid); 38 for jid in pairs(blacklist) do
39 table.insert(blacklistjids, jid);
40 end
39 end 41 end
40 return { blacklistjids = blacklistjids }; 42 return { blacklistjids = blacklistjids };
41 end, function(fields, form_err) 43 end, function(fields, form_err)
42 if form_err then 44 if form_err then
43 return { status = "completed", error = { message = "Problem in submitted form" } }; 45 return { status = "completed", error = { message = "Problem in submitted form" } };