how to get "Server" in iq_handler?

Hi, I'm a newbie, writing an iq handler.

I need to run odbc sql query in iq handler but I haven't figured it out how to get Server to call sql query.
I have been very struggling to figure this out..please help me.

process_iq(From, To, IQ) ->
LServer = jlib:nameprep(Server),
Result = ejabberd_odbc:sql_query(LServer,[<<"select * from sample_table where username='">>, User,<<"';">>]),
?INFO_MSG("~s", Result),

And I'm using im(). for debugging. but It keep crushing on mac, so not really helpful. Is there any other debugging tool I can use??

Thanks

Never mind, I found solution. I just need to do this LServer = To#jid.lserver,

maybe too late: User =

maybe too late:

User = To#jid.luser,
Server = To#jid.lserver,
...

Syndicate content