Make ejabberd pick up changes in external roster

Hi,

So I've written a custom roster that use an external web service to download roster information. This has worked really well for a few months now. But there is one problem:

How can Ejabberd know when the roster changes?

Say, for example, that there are two users: "foo" and "bar". Both have empty rosters. Foo logs on and the roster is fetched from the web service (empty). Then the web service decides to let them be subscribed to each other, but Ejabberd does not know that anything has changed, so it does not update the roster.

Then Bar logs on. Ejabberd fetches the roster for Bar, which now contains Foo. Is the roster of Foo and Bar now out of sync in Ejabberd (Foo with an empty roster, and Bar with Foo in his roster)?

I got a tip to use

I got a tip to use add_rosteritem and delete_rosteritem in the HTTP API. I tested and they seem to be somewhat usable: if add_rosteritem is called for a currently connected user, that user is notified of the new roster item. However I have two problems:

Our web service has a bit complex method for building the roster. It's no problem to generate a complete list of roster items, but to find what roster items have been removed and added is not trivial. So I would much prefer a solution where Ejabberd could be notified that the roster for a specific user has been updated and should be refetched in its entirety.

The second thing is that as far as I understand it add_rosteritem is supposed to add a roster item to the database. Since our web service may not be changed by ejabberd I've left those methods empty, but if I had implemented them it would lead to an infinite loop: a roster item is added on the web service, which leads to add_rosteritem being called, which leads to a roster item being added to the web service ...

So add_rosteritem/delete_rosteritem are quite hard to use and they don't really seem to fit, even if it's possible to make it work with them...

Btw, I also noted that the HTTP API function get_roster actually fetch the roster from the web service, but sadly the roster of the connected users are not updated.

Syndicate content