Where does openfire store roster values except the database? - xmpp

I am implementing xmpp chat server with openfire and mysql. Openfire does create a lot of tables in the db. It has roster table but only adding rows there doesn't creates roster where as adding rows in the user table creates the user and I am able to login with the user. So my question is does openfire stores the rosters anywhere else because if I delete the entries from the roster table it still shows previous roster.

Deleting roster does reflect on the roster but it will take some time as openfire store cache. If you go to Server manager->cache summary you can see the list of cache. Just delete the Roster cache, you can see that roseters are same as it is in the database. i don't think openfire store roster values anywhere else. And if you add/delete roster do it with User service plugin or make your own plugin with java don't just delete/update it on database.

It likely caches the roster in memory. If you were to stop the server, make the database change, then start the server, you might see the changes reflected. That doesn't work well in practice, so you may need to use protocol to change the roster.

Related

Synchronizing roster with the jabber server while user is offline

I am using ejabbered with converse.js and I am playing around with user administration on ejabberd admin panel, more precisely with adding/removing a user from and to a shared group.
While the user is online(converse client is connected to the server) any changes I do in admin panel are reflected in the client immediately. When I add or remove user to and from a group, contacts are updated appropriately. I can also see the roster add/remove messages in the websocket connection as I submit changes in the admin panel.
While user is offline(converse client is not connected) and I add the user to the new shared group, next time user connects, he will see the updated contact list(new contacts are added on the client), BUT if I remove the user from a shared group while he is offline, next time he comes online, the roster will not be changed. Even if I click the contacts refresh button, no contact will be removed.
In order words, only roster additions are respected while user is offline.
Now I kinda understand what's going on, since "remove" message is essentially missed by the client, but I am still wondering, is there any way to synchronize roster items between conversejs and ejabberd in such a way that they are 1 to 1 even while user is offline?
I can reproduce that problem using ejabberd from git and Converse 9.1.0. It seems Converse stores the roster in the webbrowser, and restores it at login, probably to save network consumption.
I disabled this option in Converse, and now the roster is requested at every login:
https://conversejs.org/docs/html/configuration.html#clear-cache-on-logout
Offtopic: during the last weeks, I've added some improvements to administer mod_conversejs, see
https://github.com/processone/ejabberd/commits/master/src/mod_conversejs.erl

Which XEPs or eJabberd modules would be most suitable for conditionally and immediately changing the group of users a user is subscribed to?

Imagine that a database connected to an XMPP server stores users, it also stores an extra data column (let's call it dataId) for each user. The data column can take on three values: 1, 2, or 3.
In an XMPP client that logs in to the server, a list of users is displayed along with their XMPP presence status. The list displays users that all have the same value of of dataId. The client can change the dataId value that is displayed, meaning that if he switches the value, then the user is now somehow subscribed to the presence of the new list of users, but not to the old list of users.
I wonder if someone with experience with XMPP has a suggestion as to which XEPs or corresponding eJabberd (or Prosody) modules could be used or are best suited for this type of functionality.
I am slowly going through the XEPs, but there are a lot of them, and it's not clear as of yet which modules could be used, or if I would perhaps need to set up some custom code on my XMPP server to handle this.
You can take a look at XEP-0140. This behaves similar to rosters except that all users in a shared roster group will be able to see all other users in the group. You can create multiple shared roster groups and easily switch a user between them by adding or removing the user from the group. You can also have nested groups. You can look at the example on using shared roster groups for different cases here, using ejabberd.

Server managed roster in Tigase

Generally in messenger services, user adds or deletes contacts and let knows server about it. Server then takes necessary actions.
However, our requirement is "server decides contacts list, makes roster changes accordingly and clients receives updates about the same". How can we achieve this in Tigase?
There is a dedicated API in the Tigase just for that. It is called a DynamicRoster. Maybe the name is the most accurate. Dynamic because it is managed by the server and it can change any time user requests the roster.
Anyway, there are code examples in the Tigase main code repository. You can have multiple dynamic rosters active at the same time and they can retrieve contacts from different locations.
There is also a roster protocol extension which allows you to keep extra information for the contacts in the dynamic roster such as phone numbers, etc... More info about this o the Tigase.org website in the devel guide section.
Hope this helps.

How can we make ejabberd server use existing users data, instead of creating a new database for roster?

Suppose a website has already registered users, and has a way for them to add and remove friend from their own friendlist through website.
Now, I want to use ejabberd xmpp server for getting presence information in real-time, but I don't want to have xmpp server to create new database for roster.
Is there any way to configure ejabberd to avoid data duplication on both ejabberd server and website server?
If you don't want to write a custom ejabberd module, you can configure ejabberd to load rosters from a SQL database. If all your rosters modifications are done by your webapp, then from ejabberd point of view the DB is "read only", and you could write a SQL view that has the schema expected by ejabberd but uses the data tables you already have.
See table definitions https://github.com/processone/ejabberd/blob/master/src/odbc/mysql.sql , you need "rosterusers" and "rostergroups" table. Note that this approach has some limitations. Changes in roster won't be seen immediately by connected users unless your application informs ejabberd about that, so ejabberd can inform the clients. For this you probably need to write custom code anyway, and learn about roster push http://xmpp.org/rfcs/rfc3921.html#roster
Or you can write your own custom module to access your roster data.
By default Ejabberd use Mnesia database for Users and Roster etc.
You can configure Ejabberd with external database like SQL SERVER, MySQL, Postgress etc.
You have to configure the ejabberd to use external database (ex: odbc) instead of internal database.
Please see the below to configure Ejabberd with MySQL:
http://iohq.net/index.php?title=Building_an_Ejabberd_Server_with_MySql
After that right a sql script to transfer your existing users in "users" and "rosteruser" table with proper subscription value. Changes in roster done directly in "rosteruser" won't be seen immediately by connected users. To resolve this you can get the friend request confirmation event from application logic (php/asp.net/java) and than add roster through XMPP client. Using this process all roster updation events will be reflected on all connected.

Openfire - Groups not updated on Roster from Database using custom DB

I made this question over at the Openfire groups, but it seems to be pretty quiet out there. Maybe someone here at SO works with Xiff/Openfire and has a clue about this:
We are using an external database for users and groups, on Openfire 3.6.4 through Xiff 3.0 beta with our own client.
When a user is added on our database, the roster doesn't get updated. I am logged in as "User1". "User2" is added to the database to the same shared group, so I should see him in my roster. User2 can login and see User1 on his roster, but User1's roster hasn't been updated. Even after log out, User2 still doesn't show up on User1's roster.
Apparently the group is being cached or something. Where should I be looking at for a fix to this problem? Xiff? OpenFire? I found about the property "cache.name.maxLifetime" in the docs, but I'm not sure if this is the property I should be using to get groups to update the members.
In case anybody gets here looking for an answer to this question, you can follow it here:
Groups not updated on Roster from Database using custom DB
There's a partial solution over there at the Ignite Realtime forums.
A better approach would be to use roster protocol (see RFC 3921, section 7) to modify the roster, perhaps by writing a component for OpenFire. This will modify the caches in transit, as well as sending notifications to clients that are currently logged in for the user. As well, you won't have issues with your changes getting overwritten.