Adding users to roster with script

Hi,

I want to add users to roster through my script at random times and at the same time want to give freedom to user to add friends to there roster through spark client.

Can anyone suggest me how to resolve the problem of managing rosterID in this case.

As there may be a case when my script and user would be adding friends to the roster at the same time and in this case there may arise a rosterID duplication conflict as the spark client manages the rosterIDs in batches of five.

Thanks

waiting with anticipation

lock table

note next jiveID

Incremented next jiveID value as necessary and update the table with new value

unlock table

do your insert(s) with the noted jiveID

the devs can tell us if wildfire will be pissed off if it finds the table locked, but the up-side is that noting the jiveID is a very fast operation so the table will only be locked for a very very short time.

devs? will jive be mad?

Hey guys,

Modified rosters is something that should be done at the API level and not directly in the database if you want to avoid having to reboot the server. Going directly to the database means that an already loaded roster will not be updated in memory and even if you clean up the caches it won’'t be pushed to the logged client.

If you want to avoid having to restart the server then I would recommend writing an plugin that creates new users and adds them to the roster. Since the plugin will use Wildfire’'s API then the db will be correctly updated, objects in memory will get updated and roster will be pushed to logged users. Moreover, writing such plugin is really easy.

As a sample code I attached a plugin that creates new users, populates rosters and creates vcards.

Let us know if you need any help.

Regards,

– Gato

Hi Jerm,

Thanks for your suggestion I hope it will work for me.

Can you help me out on one more thing i.e.

Is there any option to deactivate contact addition (roster addition) through spark client as it will reduce the problem of concurrent updation and insertion to the database, just like we can disable account subscriptions through spark client.

Thanks

Hi dombiak_gaston,

The information provided by you is really helpful but I am trying this thing through PHP and wondering how can I use the java plugin with it.

Although java can be bridged with php but for that php has to be installed with JAVA enabled which is not the case with me.

Can you suggest me how to do this in the current situation.

Thanks & Regards