Skip to content

Commit

Permalink
Make remove_domain hook host type specific
Browse files Browse the repository at this point in the history
  • Loading branch information
arcusfelis committed Apr 23, 2021
1 parent 0c8c546 commit 4db482c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions big_tests/tests/domain_removal_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,4 @@ mam_muc_removal(Config0) ->
escalus_fresh:story_with_config(Config0, [{alice, 1}], F).

run_remove_domain() ->
Acc = #{},
rpc(mim(), ejabberd_hooks, run_fold,
[remove_domain, domain(), Acc, [domain(), domain()]]).
rpc(mim(), mongoose_hooks, remove_domain, [domain(), domain()]).
4 changes: 2 additions & 2 deletions src/auth/ejabberd_auth.erl
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ start() ->
-spec start(HostType :: binary()) -> 'ok'.
start(HostType) ->
ensure_metrics(HostType),
ejabberd_hooks:add(remove_domain, global, fun remove_domain/3, 50),
ejabberd_hooks:add(remove_domain, HostType, ?MODULE, remove_domain, 50),
lists:foreach(
fun(M) ->
M:start(HostType)
end, auth_modules_for_host_type(HostType)).

-spec stop(HostType :: binary()) -> 'ok'.
stop(HostType) ->
ejabberd_hooks:delete(remove_domain, global, fun remove_domain/3, 50),
ejabberd_hooks:delete(remove_domain, HostType, ?MODULE, remove_domain, 50),
lists:foreach(
fun(M) ->
M:stop(HostType)
Expand Down
2 changes: 1 addition & 1 deletion src/mongoose_hooks.erl
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ disable_domain(HostType, Domain) ->
Domain :: jid:lserver(),
Result :: ok.
remove_domain(HostType, Domain) ->
ejabberd_hooks:run_global(remove_domain, ok, [HostType, Domain]).
ejabberd_hooks:run_for_host_type(remove_domain, HostType, #{}, [HostType, Domain]).

-spec node_cleanup(Node :: node()) -> Acc :: map().
node_cleanup(Node) ->
Expand Down

0 comments on commit 4db482c

Please sign in to comment.