erlangxmppejabberdrostering

ejabberd and custom roster


I have already a very simple website with a quite good amount of trafic.

So I decided to add a web chat on with, to let my users chat among their friendship. I have decided to use ejabberd to complete this task. The problem is: I have already 2 table ( users[uid, nickname, pass], and relationships[rid, uid, uid2]. How can I tell to ejabber to work with the data inside these tables? Can I find any module, like the auth's one, to edit and to adapt for my purpose?

EDIT

If I don't want to use rosterusers table, but directly my elationships[rid, uid, uid2], have you any advice on what should I change?

1) first of all, inside odbc_queries, the query inside the function get_roster to

"select uid, uid2 from relationships "
       "where uid ='", Username, "'"]).

2) the "tuple columns's checker" inside mod_roster_dbc the function get_roster

3) then the function raw_to_record to something like

raw_to_record(LServer, {Uid,Uid2}) ->
case  jlib:make_jid(Uid2, LServer, "") of
error ->
    error;
JID ->
    LJID = jlib:jid_tolower(JID),
    Subscription = both,
    Ask = both,

      end,
    #roster{usj = {Uid, LServer, LJID},
        us = {Uid, LServer},
        jid = LJID,
        name = "",
        subscription = Subscription,
        ask = Ask,
        askmessage = ""}
end.

Then?


Solution

  • For contact lists, you need to define your own roster module.

    You could use mod_roster or mod_roster_odbc as starting point. Note that those modules are fairly complex and provide read/write access to rosters, subscriptions, etc. In your case you probably need only read access (as the friend relationships are manged by your website), so the implementation will be much simpler (for example you will need to handle "get" IQ request, but nothing to do on "set" IQ requests).

    If you need changes in relationships to be immediately visible to connected users (rather than on next login), you will need to provide an API in ejabberd side to be called from your webapp on each change, to be able to "push" the updated roster info to the connected users.