Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored hook handlers in mod_pubsub #3879

Merged
merged 1 commit into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How comes dialyzer didn't complain here 😢

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