25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

gen_mod: Add support to specify a hook global, not vhost-specific

This commit is contained in:
Badlop 2024-05-15 16:17:30 +02:00
parent 0d1cbc62d4
commit fba915e04e

View File

@ -61,6 +61,7 @@
-type component() :: ejabberd_sm | ejabberd_local. -type component() :: ejabberd_sm | ejabberd_local.
-type registration() :: -type registration() ::
{hook, atom(), atom(), integer()} | {hook, atom(), atom(), integer()} |
{hook, atom(), atom(), integer(), binary() | global} |
{hook, atom(), module(), atom(), integer()} | {hook, atom(), module(), atom(), integer()} |
{iq_handler, component(), binary(), atom()} | {iq_handler, component(), binary(), atom()} |
{iq_handler, component(), binary(), module(), atom()}. {iq_handler, component(), binary(), module(), atom()}.
@ -341,7 +342,9 @@ add_registrations(Host, Module, Registrations) ->
lists:foreach( lists:foreach(
fun({hook, Hook, Function, Seq}) -> fun({hook, Hook, Function, Seq}) ->
ejabberd_hooks:add(Hook, Host, Module, 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); ejabberd_hooks:add(Hook, Host, Module1, Function, Seq);
({iq_handler, Component, NS, Function}) -> ({iq_handler, Component, NS, Function}) ->
gen_iq_handler:add_iq_handler( gen_iq_handler:add_iq_handler(
@ -356,7 +359,9 @@ del_registrations(Host, Module, Registrations) ->
lists:foreach( lists:foreach(
fun({hook, Hook, Function, Seq}) -> fun({hook, Hook, Function, Seq}) ->
ejabberd_hooks:delete(Hook, Host, Module, 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); ejabberd_hooks:delete(Hook, Host, Module1, Function, Seq);
({iq_handler, Component, NS, _Function}) -> ({iq_handler, Component, NS, _Function}) ->
gen_iq_handler:remove_iq_handler(Component, Host, NS); gen_iq_handler:remove_iq_handler(Component, Host, NS);