From fba915e04ed22751d55527c0ebb3afa2f9e4e30e Mon Sep 17 00:00:00 2001 From: Badlop Date: Wed, 15 May 2024 16:17:30 +0200 Subject: [PATCH] gen_mod: Add support to specify a hook global, not vhost-specific --- src/gen_mod.erl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gen_mod.erl b/src/gen_mod.erl index 908755b99..58d855938 100644 --- a/src/gen_mod.erl +++ b/src/gen_mod.erl @@ -61,6 +61,7 @@ -type component() :: ejabberd_sm | ejabberd_local. -type registration() :: {hook, atom(), atom(), integer()} | + {hook, atom(), atom(), integer(), binary() | global} | {hook, atom(), module(), atom(), integer()} | {iq_handler, component(), binary(), atom()} | {iq_handler, component(), binary(), module(), atom()}. @@ -341,7 +342,9 @@ add_registrations(Host, Module, Registrations) -> lists:foreach( fun({hook, Hook, Function, Seq}) -> ejabberd_hooks:add(Hook, Host, Module, Function, Seq); - ({hook, Hook, Module1, Function, Seq}) -> + ({hook, Hook, Function, Seq, Host1}) when is_integer(Seq) -> + ejabberd_hooks:add(Hook, Host1, Module, Function, Seq); + ({hook, Hook, Module1, Function, Seq}) when is_integer(Seq) -> ejabberd_hooks:add(Hook, Host, Module1, Function, Seq); ({iq_handler, Component, NS, Function}) -> gen_iq_handler:add_iq_handler( @@ -356,7 +359,9 @@ del_registrations(Host, Module, Registrations) -> lists:foreach( fun({hook, Hook, Function, Seq}) -> ejabberd_hooks:delete(Hook, Host, Module, Function, Seq); - ({hook, Hook, Module1, Function, Seq}) -> + ({hook, Hook, Function, Seq, Host1}) when is_integer(Seq) -> + ejabberd_hooks:delete(Hook, Host1, Module, Function, Seq); + ({hook, Hook, Module1, Function, Seq}) when is_integer(Seq) -> ejabberd_hooks:delete(Hook, Host, Module1, Function, Seq); ({iq_handler, Component, NS, _Function}) -> gen_iq_handler:remove_iq_handler(Component, Host, NS);