This thread is archived
26 Replies Last post: Jan 2, 2007 4:37 AM by NK  
Oscar   18 posts since
Jul 24, 2006
Currently Being Moderated

Jul 24, 2006 2:05 PM

Creating chat room using SQL

Hi, I just registered and have some doubts

 

I am trying to add chat rooms by doing manual inserts to the DB, I am currently using PostgreSQL, something like this:

 

insert into mucroom (roomid,creationdate,modificationdate,name,naturalname,description,lockeddate,e mptydate,canchangesubject,maxusers,publicroom,moderated,membersonly,caninvite,pa ssword,candiscoverjid,logenabled,subject,rolestobroadcast,usereservednick,cancha ngenick,canregister) values (''?'',''001153767614000'',''001153767614000'',''?'',''?'',''?'',0,0,1,''999'', 0,1,1,0,'''',0,1,''?'',7,0,0,0);commit;

 

and the insert works fine, the room is inserted to the database but it never appears on the admin console even after I restart the server/clean cache.

 

Am I doing something wrong or I just cant create groups using DB commands?.

 

Thanks in advance

Aznidin KeyContributor 508 posts since
Jul 5, 2006
Currently Being Moderated
Jul 26, 2006 2:32 PM in response to: Oscar
Re: Creating chat room using SQL

The reason it didn''t appear in the admin console was that the emptyDate field was 0 in your query. The following condition needs to be true:

 

emptyDate > (currentdate - 30 days)

 

because Wildfire will not load inactive rooms.

 

That might answer your question.

-


But IMHO, it might not solve your problem. I guess your plan of getting a module to directly modify the MUC tables might not work as you''d expect. Wildfire will load MUC data once at startup and everything is placed in cache. Your manual changes after the startup will be overwritten by the cache data and you''re all back to square one.

 

One way to solve the problem may be to develop your module as Wildfire plugin and have it grab the internal MUC server instance and call it''s public methods that perform your intended database actions. I have no experience doing this anyway and I might be wrong

LG KeyContributor 4,984 posts since
Dec 13, 2005
Currently Being Moderated
Jul 26, 2006 3:47 PM in response to: Oscar
Re: Creating chat room using SQL

Hi,

 

it may be necessary to modify some of the JiveID values after creating a room as Wildfire does not use a sequence / constraint while creating a room.

 

Could you image to use the Web Admin console to create the rooms? There a simple HTTP POST should do it. Or you could use Smack and write a short application to create rooms.

 

LG

LG KeyContributor 4,984 posts since
Dec 13, 2005
Currently Being Moderated
Jul 26, 2006 4:07 PM in response to: LG
Re: Creating chat room using SQL

Hi,

 

as roomid you must use the ID you find in JIVEID.IDTYPE=23. After creating the room you need to to increase the ID in the JIVEID table.

 

LG

Andreas Monitzer KeyContributor 409 posts since
Mar 6, 2006
Currently Being Moderated
Jul 28, 2006 7:36 PM in response to: Oscar
Re: Creating chat room using SQL

The easiest solution would probably be a small java app using Smack that creates those rooms via a regular XMPP connection. You can even set other owners etc using the registration form, fully automated.

Aznidin KeyContributor 508 posts since
Jul 5, 2006
Currently Being Moderated
Aug 29, 2006 2:43 AM in response to: Oscar
Re: Creating chat room using SQL

Hi oscar,

 

I added the following code to the class.jabber.php and is still not working:

 

<iq from=''me@server''

id=''owner1''

to=''206@conference.server''

type=''set'' >

<query xmlns=''http://jabber.org/protocol/muc#admin''>

<item affiliation=''member'' jid=''he@server'' />

</query>

</iq>

 

Edit: the thing that I find weird is I create the room, then add the owner to it, then join the room with the admin of the group and that works, but when I try to add members to that group and use XML for that, seems like is not working.

 

 

Can you try to send a full JID i.e. with a resource in the from attribute of your IQ packet? Try this instead:

 

Then check if you receive a reply from the server whether it''s an error or a success like for example: ]]>

 

Oh and I even tried and add more members to the mucaffiliation table but that doesnt work either, I guess you can say I am desperate right now, reading everything I can all around but cant find a solution to my problem.

Don''t bother trying to insert anything in the MUC tables directly. I''m pretty sure it won''t work most of the time.

I read some other posts about modyfing the users plugin in order to add members to a muc, the thing is I need to add several members at the same time, I know almost nothing about java but is there a way to use it for multiple accounts at the same time?

According to the protocol, you should be able to enter multiple items in IQ set, e.g.:

 

... ]]>

Aznidin KeyContributor 508 posts since
Jul 5, 2006
Currently Being Moderated
Aug 29, 2006 11:06 AM in response to: Oscar
Re: Creating chat room using SQL

Oscar,

 

Thanks, as soon as I get back to work I willl try that, one question here, what is the id paramater? I just used owner 1 as I thought well, is the first owner of the group though i have no idea if that is valid.

 

It''s 100% valid. In fact ''id'' is required in an IQ stanza/packet. When you send an IQ packet you would expect something in return. The ''id'' serves as a reference for you in an asynchronous jabber environment. It could be any value, but many clients that I know implement some kind of incremental values. It''s normal that clients send a set of IQ packets at a time with different ''id''s. The responses may come in different order. It''s the id that identify which response belongs to which IQ request. You may find the all about XMPP core spec in RFC3920.

 

I read that you can add more than one at the time and thats my main idea, but first I need to make it work for one.

 

Hmm... that I''ve never heard of. Where did you read it? And I wonder what could be your idea?