ejabberdstropheejabberd-moduleejabberd-hooks

How to save extra fields in archive table using Ejabberd mod_mam (Message Archive Management, XEP-0313)?


I am using Ejabberd server for chatting application. It works to save messages in arhieve table, but I want to save additional field in the table when message is sent. This field will be per message.


Solution

  • Igor, Thanks for your answer, looks promising, but I did something else which I want to share here. I have installed ejabberd from source code with help of this link http://www.blikoon.com/networking/how-to-install-ejabberd-on-linux-ubuntu then I modified mod_mam_sql.erl file in src folder. Code I modified is as follow. I recompiled module and it worked.

    Body = fxml:get_subtag_cdata(Pkt, <<"body">>),
    Resid = fxml:get_subtag_cdata(Pkt, <<"resid">>),
    Ownuid = fxml:get_subtag_cdata(Pkt, <<"ownuid">>),
    SType = jlib:atom_to_binary(Type),
    case ejabberd_sql:sql_query(
         LServer,
         ?SQL("insert into archive (username, timestamp,"
                    " peer, bare_peer, xml, txt, kind, nick,resid,Ownuid) values ("
    	"%(SUser)s, "
    	"%(TSinteger)d, "
    	"%(LPeer)s, "
    	"%(BarePeer)s, "
    	"%(XML)s, "
    	"%(Body)s, "
    	"%(SType)s, "
    	"%(Nick)s, "
    	"%(Resid)s, "
    	"%(Ownuid)s)")) of
    {updated, _} ->
     {ok, ID};