Skip to content

Commit

Permalink
Refactored hook handlers in mod_pubsub
Browse files Browse the repository at this point in the history
  • Loading branch information
pawlooss1 committed Nov 29, 2022
1 parent 29e8228 commit 929be75
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 114 deletions.
2 changes: 1 addition & 1 deletion src/mod_ping.erl
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ iq_ping(Acc, _From, _To, #iq{sub_el = SubEl} = IQ, _) ->

-spec handle_remote_hook(Acc, Params, Extra) -> {ok, Acc} when
Acc :: term(),
Params :: #{tag := atom(), args := term(), c2s_state := ejabberd_c2s:state()},
Params :: #{tag := atom(), hook_args := term(), c2s_state := ejabberd_c2s:state()},
Extra :: gen_hook:extra().
handle_remote_hook(HandlerState, #{tag := mod_ping, hook_args := Args, c2s_state := C2SState}, _) ->
{ok, handle_remote_call(Args,
Expand Down
10 changes: 8 additions & 2 deletions src/mongoose_hooks.erl
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,10 @@ packet_to_component(Acc, From, To) ->
Pid :: pid(),
Result :: mongoose_acc:t().
presence_probe_hook(HostType, Acc, From, To, Pid) ->
run_hook_for_host_type(presence_probe_hook, HostType, Acc, [From, To, Pid]).
Params = #{from => From, to => To, pid => Pid},
Args = [From, To, Pid],
ParamsWithLegacyArgs = ejabberd_hooks:add_args(Params, Args),
run_hook_for_host_type(presence_probe_hook, HostType, Acc, ParamsWithLegacyArgs).

%%% @doc The `push_notifications' hook is called to push notifications.
-spec push_notifications(HostType, Acc, NotificationForms, Options) -> Result when
Expand Down Expand Up @@ -1672,8 +1675,11 @@ update_inbox_for_muc(HostType, Info) ->
Features :: unknown | list(),
Result :: mongoose_acc:t().
caps_recognised(Acc, From, Pid, Features) ->
Params = #{from => From, pid => Pid, features => Features},
Args = [From, Pid, Features],
ParamsWithLegacyArgs = ejabberd_hooks:add_args(Params, Args),
HostType = mongoose_acc:host_type(Acc),
run_hook_for_host_type(caps_recognised, HostType, Acc, [From, Pid, Features]).
run_hook_for_host_type(caps_recognised, HostType, Acc, ParamsWithLegacyArgs).

%% PubSub related hooks

Expand Down
Loading

0 comments on commit 929be75

Please sign in to comment.