How can I do custom MySQL Queries with ejabberd?

We are currently building a social networking site. Think something along the lines of facebook. At least in functionality.

We have an existing database of users and we would like to implement a realtime chat function similar too facebook chat based on xmpp.
Ideally, each user that registers on our site, should automatically have a chat account with the same password. Also, if you chat via the website, people in your contact list that are connected via xmpp client such as pidgin can see that you are online and chat with you.

I think you get the general idea.

So far, we are using a external authentication script, to authenticate users via MySQL with our existing user database. But how do we go about things such as contact lists, and tracking user states (offline/online).

Also we want to implement a chat history, so that regardless of you chatting via the website or a chatclient like pidgin, you can pull up a chat history for each user in your contact list.

We are new to implementing a xmpp service ourselves, as such it's still a bit overwhelming. Our choice for ejabberd isn't set in stone, and Openfire might be a viable solution as well, since it seems to more easily allow for custom MySQL queries. But I would rather find a solution using ejabberd, than having to deal with a Tomcat server.

I'd be grateful if anyone could point me in a general direction or so.

Perhaps a solution already exists, but due to my unfamiliarity with xmpp terminology, it could be that I'm just blind to the results that google and forum searches have come up with so far.

I just finished building

I just finished building almost exactly the same thing. I kept all of the xmpp authentication separate from the regular users' auth. The system uses xmpp on the users' behalf. I used Strophe in the browser to connect and pass the session info to Strophe via mod_warm_bindings so the web client doesn't need to know auth.

I don't think MySQL is necessary. However, ejabberd does have pieces that allow you to authenticate to an external source if that's what you want. As a matter of fact, I'd say MySQL is the wrong path completely.

I used MySQL and found that the xmpp challenge/response auth was too heavy for sending quick commands like managing users and pubsub. For most things, I was happy with mod_rest and mod_admin_extra. However, I ended up using a read-only MySQL user for some queries that weren't available via those methods.

NOW... I'm looking at converting away from MySQL and back to mnesia. I believe that mnesia will offer better clustering possibilities and maybe even better performance... Clustered MySQL doesn't support views and some index naming used in mod_mysql and therefore doesn't support ejabberd.

To access mnesia directly, I'm either going to dig into some erlang and build off of mod_admin_extra. Currently, mod_admin_extra accepts random xml stanzas but in most cases, doesn't return anything because, I believe, most xmpp commands aren't meant to be synchronous. OR, I'm going to look at a ruby/mnesia bridge that exists out there for reads into mnesia.

I basically had a "doh" moment when I was setting up the mnesia clustering... which seems to work really well and is build for just the kind of things we need to do.

I had more to say about this

I had more to say about this before: http://www.ejabberd.im/node/8979

Syndicate content