Skip to content

Commit

Permalink
Merge pull request #3782 from esl/hooks/mod_event_pusher_push
Browse files Browse the repository at this point in the history
Refactored hook handler in mod_event_pusher_push module
  • Loading branch information
NelsonVides authored Oct 4, 2022
2 parents 0a7164f + 572b0d3 commit e38a0d4
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/event_pusher/mod_event_pusher_push.erl
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@
-export([is_virtual_pubsub_host/3]).
-export([disable_node/4]).

-ignore_xref([
iq_handler/4, remove_user/3
]).
-ignore_xref([iq_handler/4]).

%% Types
-type publish_service() :: {PubSub :: jid:jid(), Node :: pubsub_node(), Form :: form()}.
Expand All @@ -68,7 +66,7 @@ start(HostType, Opts) ->
mod_event_pusher_push_backend:init(HostType, Opts),
mod_event_pusher_push_plugin:init(HostType, Opts),
init_iq_handlers(HostType, Opts),
ejabberd_hooks:add(remove_user, HostType, ?MODULE, remove_user, 90),
gen_hook:add_handler(remove_user, HostType, fun ?MODULE:remove_user/3, #{}, 90),
ok.

start_pool(HostType, #{wpool := WpoolOpts}) ->
Expand All @@ -82,7 +80,7 @@ init_iq_handlers(HostType, #{iqdisc := IQDisc}) ->

-spec stop(mongooseim:host_type()) -> ok.
stop(HostType) ->
ejabberd_hooks:delete(remove_user, HostType, ?MODULE, remove_user, 90),
gen_hook:delete_handler(remove_user, HostType, fun ?MODULE:remove_user/3, #{}, 90),

gen_iq_handler:remove_iq_handler(ejabberd_sm, HostType, ?NS_PUSH),
gen_iq_handler:remove_iq_handler(ejabberd_local, HostType, ?NS_PUSH),
Expand Down Expand Up @@ -128,12 +126,14 @@ push_event(Acc, _) ->
%%--------------------------------------------------------------------
%% Hooks and IQ handlers
%%--------------------------------------------------------------------
-spec remove_user(Acc :: mongoose_acc:t(), LUser :: jid:luser(), LServer :: jid:lserver()) ->
mongoose_acc:t().
remove_user(Acc, LUser, LServer) ->
-spec remove_user(Acc, Params, Extra) -> {ok, Acc} when
Acc :: mongoose_acc:t(),
Params :: #{jid := jid:jid()},
Extra :: map().
remove_user(Acc, #{jid := #jid{luser = LUser, lserver = LServer}}, _) ->
R = mod_event_pusher_push_backend:disable(LServer, jid:make_noprep(LUser, LServer, <<>>)),
mongoose_lib:log_if_backend_error(R, ?MODULE, ?LINE, {Acc, LUser, LServer}),
Acc.
{ok, Acc}.

-spec iq_handler(From :: jid:jid(), To :: jid:jid(), Acc :: mongoose_acc:t(),
IQ :: jlib:iq()) ->
Expand Down

0 comments on commit e38a0d4

Please sign in to comment.