-spec process_message_in(state(), message()) -> {boolean(), state()}.
process_message_in(State, #message{type = T} = Msg) ->
- case filter_incoming_message(State, Msg) of
+ case privacy_check_packet(State, Msg, in) of
allow ->
{true, State};
deny when T == groupchat; T == headline ->
{false, State}
end.
-filter_incoming_message(State, Msg) ->
- case privacy_check_packet(State, Msg, in) of
- allow ->
- #{lserver := LServer} = State,
- case ejabberd_hooks:run_fold(
- c2s_filter_incoming_packet,
- LServer,
- allow,
- [State, Msg]) of
- allow ->
- allow;
- deny ->
- deny
- end;
- deny ->
- deny
- end.
-
-spec process_presence_in(state(), presence()) -> {boolean(), state()}.
process_presence_in(#{lserver := LServer, pres_a := PresA} = State0,
#presence{from = From, to = To, type = T} = Pres) ->
-export([start/2, stop/1,
depends/2, mod_opt_type/1]).
--export([filter_packet/3]).
+-export([filter_packet/1]).
-include("xmpp.hrl").
-include("ejabberd.hrl").
-define(SETS, gb_sets).
start(Host, _Opts) ->
- ejabberd_hooks:add(c2s_filter_incoming_packet, Host,
- ?MODULE, filter_packet, 50),
+ ejabberd_hooks:add(user_receive_packet, Host,
+ ?MODULE, filter_packet, 25),
ok.
stop(Host) ->
- ejabberd_hooks:delete(c2s_filter_incoming_packet, Host,
- ?MODULE, filter_packet, 50),
+ ejabberd_hooks:delete(user_receive_packet, Host,
+ ?MODULE, filter_packet, 25),
ok.
-filter_packet(deny = Acc, _State, _Msg) ->
- Acc;
-filter_packet(Acc, State, Msg) ->
+filter_packet({#message{} = Msg, State} = Acc) ->
From = xmpp:get_from(Msg),
LFrom = jid:tolower(From),
LBFrom = jid:remove_resource(LFrom),
end,
if
Drop ->
- deny;
+ {drop, State};
true ->
Acc
end
- end.
-
+ end;
+filter_packet(Acc) ->
+ Acc.
sets_bare_member({U, S, <<"">>} = LBJID, Set) ->
case ?SETS:next(?SETS:iterator_from(LBJID, Set)) of