[ejabberd] process_received_packet hook (ejabberd alpha 3)

Samuel Wejéus samuelw at opera.com
Fri Aug 5 18:24:47 MSD 2011


Hello list!

I'm writing a module where i need to intercept stanzas of type 'message' 
sent between users and came across an odd behaviour:

I set up two hooks:

ejabberd_hooks:add(user_send_packet, HostB, ?MODULE, 
process_sent_packet, 50),
ejabberd_hooks:add(user_receive_packet, HostB, ?MODULE, 
process_receive_packet, 50).

And the handler look like this (for now..)

process_receive_packet(JID, From, To, Packet) ->
?INFO_MSG("####### ~p~n~p~n~p~n",[JID,From,To]),
     case exmpp_message:is_message(Packet) of
         true -> process_message(received, From, To, Packet);
         _ -> ok
     end.

The problem is the output from ?INFO_MSG gives:

=INFO REPORT==== 5-Aug-2011::16:18:04 ===
I(<0.510.0>:mod_chatlog:41) : ####### {jid,
<<"megatron at decepticons.com/undefined">>,
<<"megatron">>,<<"decepticons.com">>,
<<"undefined">>}
{jid,<<"megatron at decepticons.com/undefined">>,<<"megatron">>,
<<"decepticons.com">>,<<"undefined">>}
{jid,<<"megatron at decepticons.com/undefined">>,<<"megatron">>,
<<"decepticons.com">>,<<"undefined">>}

This cant be right, can it?

JID, From and To contains the same user?

Kind regards,

Samuel



More information about the ejabberd mailing list