{Pkt2, State1} -> xmpp_stream_in:send(State1, Pkt2)
end.
+-spec send_error(state(), xmpp_element(), stanza_error()) -> state().
+send_error(#{lserver := LServer} = State, Pkt, Err) ->
+ case ejabberd_hooks:run_fold(c2s_filter_send, LServer, {Pkt, State}, []) of
+ {drop, State1} -> State1;
+ {Pkt1, State1} -> xmpp_stream_in:send_error(State1, Pkt1, Err)
+ end.
+
-spec route(pid(), term()) -> ok.
route(Pid, Term) ->
Pid ! Term,
-spec process_message_in(state(), message()) -> {boolean(), state()}.
process_message_in(State, #message{type = T} = Msg) ->
+ %% This function should be as simple as process_iq_in/2,
+ %% however, we don't route errors to MUC rooms in order
+ %% to avoid kicking us, because having a MUC room's JID blocked
+ %% most likely means having only some particular participant
+ %% blocked, i.e. room@conference.server.org/participant.
case privacy_check_packet(State, Msg, in) of
allow ->
{true, State};
deny when T == groupchat; T == headline ->
- ok;
+ {false, State};
deny ->
case xmpp:has_subtag(Msg, #muc_user{}) of
true ->
ErrText = <<"Your active privacy list has denied "
"the routing of this stanza.">>,
Err = xmpp:err_not_acceptable(ErrText, Lang),
- xmpp_stream_in:send_error(State, Pres, Err);
+ send_error(State, Pres, Err);
allow when Type == subscribe; Type == subscribed;
Type == unsubscribe; Type == unsubscribed ->
Access = gen_mod:get_module_opt(LServer, mod_roster, access,
deny ->
ErrText = <<"Denied by ACL">>,
Err = xmpp:err_forbidden(ErrText, Lang),
- xmpp_stream_in:send_error(State, Pres, Err);
+ send_error(State, Pres, Err);
allow ->
ejabberd_hooks:run(roster_out_subscription,
LServer,
ErrText = <<"Your active privacy list has denied "
"the routing of this stanza.">>,
Err = xmpp:err_not_acceptable(ErrText, Lang),
- xmpp_stream_in:send_error(State, Pkt, Err);
+ send_error(State, Pkt, Err);
allow ->
ejabberd_router:route(Pkt),
State