mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-26 17:38:45 +01:00
Add new hook: c2s_filter_packet_in
The c2s_filter_packet_in hook can be used to modify or drop incoming packets before they are transmitted to the client.
This commit is contained in:
parent
b85357d280
commit
16311b73c8
@ -1694,12 +1694,23 @@ handle_info({route, From, To,
|
||||
jlib:replace_from_to_attrs(jlib:jid_to_string(From),
|
||||
jlib:jid_to_string(To), NewAttrs),
|
||||
FixedPacket = #xmlel{name = Name, attrs = Attrs2, children = Els},
|
||||
SentStateData = send_packet(NewState, FixedPacket),
|
||||
ejabberd_hooks:run(user_receive_packet,
|
||||
SentStateData#state.server,
|
||||
[SentStateData#state.jid, From, To, FixedPacket]),
|
||||
FinalState =
|
||||
case ejabberd_hooks:run_fold(c2s_filter_packet_in,
|
||||
NewState#state.server, FixedPacket,
|
||||
[NewState#state.jid, From, To])
|
||||
of
|
||||
drop ->
|
||||
NewState;
|
||||
FinalPacket = #xmlel{} ->
|
||||
SentState = send_packet(NewState, FinalPacket),
|
||||
ejabberd_hooks:run(user_receive_packet,
|
||||
SentState#state.server,
|
||||
[SentState#state.jid, From, To,
|
||||
FinalPacket]),
|
||||
SentState
|
||||
end,
|
||||
ejabberd_hooks:run(c2s_loop_debug, [{route, From, To, Packet}]),
|
||||
fsm_next_state(StateName, SentStateData);
|
||||
fsm_next_state(StateName, FinalState);
|
||||
true ->
|
||||
ejabberd_hooks:run(c2s_loop_debug, [{route, From, To, Packet}]),
|
||||
fsm_next_state(StateName, NewState)
|
||||
|
Loading…
Reference in New Issue
Block a user