Comparison

mod_firewall/mod_firewall.lua @ 2580:aaff2716f022

mod_firewall: Compatibility fix for 0.9 (no module:unhook())
author Matthew Wild <mwild1@gmail.com>
date Sat, 25 Feb 2017 17:05:40 +0000
parent 2579:5e948d1392a5
child 2583:b6b10f57aa56
comparison
equal deleted inserted replaced
2579:5e948d1392a5 2580:aaff2716f022
602 end 602 end
603 loaded_scripts[script] = { last_modified = last_modified, events_hooked = events_hooked }; 603 loaded_scripts[script] = { last_modified = last_modified, events_hooked = events_hooked };
604 module:log("debug", "Loaded %s", script); 604 module:log("debug", "Loaded %s", script);
605 end 605 end
606 606
607 --COMPAT w/0.9 (no module:unhook()!)
608 local function module_unhook(event, handler)
609 return module:unhook_object_event((hosts[module.host] or prosody).events, event, handler);
610 end
611
607 function unload_script(script, is_reload) 612 function unload_script(script, is_reload)
608 script = resolve_script_path(script); 613 script = resolve_script_path(script);
609 local script_info = loaded_scripts[script]; 614 local script_info = loaded_scripts[script];
610 if not script_info then 615 if not script_info then
611 return; -- Script not loaded 616 return; -- Script not loaded
612 end 617 end
613 local events_hooked = script_info.events_hooked; 618 local events_hooked = script_info.events_hooked;
614 for event_name, event_handler in pairs(events_hooked) do 619 for event_name, event_handler in pairs(events_hooked) do
615 module:unhook(event_name, event_handler); 620 module_unhook(event_name, event_handler);
616 events_hooked[event_name] = nil; 621 events_hooked[event_name] = nil;
617 end 622 end
618 loaded_scripts[script] = nil; 623 loaded_scripts[script] = nil;
619 if not is_reload then 624 if not is_reload then
620 module:log("debug", "Unloaded %s", script); 625 module:log("debug", "Unloaded %s", script);