Skip to content

Commit

Permalink
fix: When host is loaded muc module maybe still be nil in rayo filter.
Browse files Browse the repository at this point in the history
This can prevent outgoing calls due to error.
  • Loading branch information
damencho committed Dec 1, 2023
1 parent 99bba14 commit 45415ef
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions resources/prosody-plugins/mod_filter_iq_rayo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,25 @@ function process_set_affiliation(event)
end
end

process_host_module(main_muc_component_host, function(host_module, host)
main_muc_service = prosody.hosts[host].modules.muc;
function process_main_muc_loaded(main_muc, host_module)
module:log('debug', 'Main muc loaded');

main_muc_service = main_muc;
module:log("info", "Hook to muc events on %s", main_muc_component_host);
host_module:hook("muc-pre-set-affiliation", process_set_affiliation);
end

process_host_module(main_muc_component_host, function(host_module, host)
local muc_module = prosody.hosts[host].modules.muc;

if muc_module then
process_main_muc_loaded(muc_module, host_module);
else
module:log('debug', 'Will wait for muc to be available');
prosody.hosts[host].events.add_handler('module-loaded', function(event)
if (event.module == 'muc') then
process_main_muc_loaded(prosody.hosts[host].modules.muc, host_module);
end
end);
end
end);

0 comments on commit 45415ef

Please sign in to comment.