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

Anyone? what I am trying to do is dont let users create chat rooms as only a module I am making for another project will be the responsible for creating chat roomds/users/rosters/groups etc, all from data stored on a database, so far I got everything done except for chat rooms.

Thanks

Oscar

Message was edited by: oscarx21

Found out the room is created as I can join with a client, though is not showing in the public room on my client and admin console.

Edit: Looks like after I joined the group appear both on the admin console and my client as a public group, any ideas? that is practically good but Id really want it to appear there as soon as I create it.

Message was edited by: oscarx21

Most of it works fine now, though I really need the group to show before someone joins it, I even tried adding messages manually in order to make it visable to other users but nothing seems to work, am I missing something? I really need to do this.

Thanks

Oscar

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

Well, I changed the emptydate to the current date and is still now working as the same things happens, the room is created and only appears until I join manually.

I set most of the cache to low values, with that I managed to refresh it fast (servers suffers a little bit but helps the pourpose).

I migth try doing the last thing you said but I dont have much time right now.

Now, is there a way to simulate joining the room? I tried sending messages by doing an insert in the logs but that didnt work, I dont know much about XML, as it seems to work by joining the room, I guess I need to find a way to simulate that the admin of the room joined the room.

Thanks

Oscar

Message was edited by: oscarx21

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

I get the current jiveId from the table, then use that value to create the room, then update the jiveID table, as I said, the rooms work after joining (after being the main problem right now).

Guess I will have to implement a way for a user to join the room after I create it in order to make the room visable for other users.

Thanks

Oscar

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

Hi, yeah, I know, I always do that when I make the inserts, as I said is get the id, insert with the id as roomid, then update the jiveID table where type=23.

Thanks

Oscar

Changed some parameters in the insert (took empty date a little before current date) and after restarting the server it works, though that isnt what I want either.

I set up my cache and put expiration date to zero on everything, still not working even if I clear manually the cache (dont know why I do that), I am wondering is not a cache thing but I might be wrong.

Is there a php class that lets you join channels?, I would try some XML stuff but I know almost nothing about it yet.

I tried class.jabber.php but as far as I read, doesnt allows you to join a MUC (wich is what I seem to need in order to the room to be active without restarting).

Any help would be greatly appreciated.

Thanks

Oscar

Still cant find a way, whats the cache that affects MUCs?

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.

Went back to try and found the creator of the class.jabber.php added new functions one is for mucs, looks like they work, though I guess I am missing a couple of parameters, the XML code that sends is:

Am I missing something? maybe a wrong parameter?

I read some jabber info about MUCs but I am sure I am doing something wrong there.

Note that this code is just for joining a much and I thought about the Java idea but for now we are just developing PHP based stuff.

Thanks

Oscar

Apparently I was using some wrong parameters, read some about the JEP-0045 and solved the problem, now it works.

Thanks Guys

Oscar

Went back to work and found a problem when adding members to mucmember table and did the insert to the table, though as expected didnt work out so I tried using jabber commands with xml.

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

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.

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.

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?

Message was edited by: oscarx21

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’’ />

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:

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.:

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.

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.

Thanks

Oscar

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?

Thanks and what I meant is what you said:

That way 2 ore more owners are added.