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:replace_from_to_attrs(jlib:jid_to_string(From),
|
||||||
jlib:jid_to_string(To), NewAttrs),
|
jlib:jid_to_string(To), NewAttrs),
|
||||||
FixedPacket = #xmlel{name = Name, attrs = Attrs2, children = Els},
|
FixedPacket = #xmlel{name = Name, attrs = Attrs2, children = Els},
|
||||||
SentStateData = send_packet(NewState, FixedPacket),
|
FinalState =
|
||||||
ejabberd_hooks:run(user_receive_packet,
|
case ejabberd_hooks:run_fold(c2s_filter_packet_in,
|
||||||
SentStateData#state.server,
|
NewState#state.server, FixedPacket,
|
||||||
[SentStateData#state.jid, From, To, 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}]),
|
ejabberd_hooks:run(c2s_loop_debug, [{route, From, To, Packet}]),
|
||||||
fsm_next_state(StateName, SentStateData);
|
fsm_next_state(StateName, FinalState);
|
||||||
true ->
|
true ->
|
||||||
ejabberd_hooks:run(c2s_loop_debug, [{route, From, To, Packet}]),
|
ejabberd_hooks:run(c2s_loop_debug, [{route, From, To, Packet}]),
|
||||||
fsm_next_state(StateName, NewState)
|
fsm_next_state(StateName, NewState)
|
||||||
|
Loading…
Reference in New Issue
Block a user