Quantcast
Channel: Ignite Realtime : All Content - Openfire Dev
Viewing all articles
Browse latest Browse all 966

Roster size restriction.

$
0
0

I want to limit the roster size of users according to database requests. To be perfect, it should allow to put restriction based on subscription status (none, to, from, both), and on the domain part of the JID (to allow differences between chatrooms, users...). The reason behind this is : the "friend" status gives access to server-costly features, so we want to have strict control of it, on a per-user basis, and we don't want to have 2 different notions of "friend".

 

I see multiple ways to achieve this.

1 - Create my own RosterItemProvider (by extending DefaultRosterItemProvider). Throw an exception in the provider's createItem, that should be caught in IQRosterHandler.java::handleIQ. As the code is now, it will send a internal_server_error back, unless I change existing code to add a new exception, and send a "forbidden" packet back when it's caught.

2 - Use a plugin with a RosterEventListener, and give "addingContact" the possibility to forbid the new contact. The return value of addingContact is already used (to specify if the new roster item should be persisted by the Provider). So we either could use a new Exception for this case, or enrich the return value of addingContact to contain the 2 values. Both require changing existing code.

 

For now, the second solution seem better to me : it keeps Roster restrictions separate from Roster Provider. In my case, for example, the database containing the Rosters is the default one, but we need to connect to an other one to get the currently allowed Roster size. The first solution would imply to have 2 database connections in the RosterItemProvider. Also, the 2nd solution may be useful at some point for other plugins/core code : any RosterListener can forbid a contact being added to the Roster. But it means changing existing code to add facilities concerning only (for now) one single use case, so I would understand some reluctance.

 

Any advice is welcome


Viewing all articles
Browse latest Browse all 966

Trending Articles