ForNeVeR / Kaiwa

A modern XMPP Web client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MultiUser Join in MUC

patelvanita360 opened this issue · comments

Hello @vitalyster

Can i join multiple user at the time of room creation ?

I have tried following but its not working.

var userlist = ['8000955973@domain', '8000955974@domain', '911234@domain'];
var room = self.model.jid;
var nick = self.model.nick;
userlist.forEach(function(element) {
	opts =[{to : element}]; 
	client.invite(room,opts);
});         
         

Note, you also need to check "verbose" in log levels of chrome console to see XML

Not getting any logs. Actually Some time room created and some time not creating. Currently room creation stop working in kaiwa

Verbose is ON

Got response from ejabberd - this response i am getting on creation of room

#iq{id = <<"9152398a-11bf-4019-938f-0ecfd2f10a19">>,type = error,
    lang = <<"en">>,
    from =
        #jid{
            user = <<"vanitapatel">>,
            server = <<"conference.domain">>,resource = <<>>,
            luser = <<"vanitapatel">>,
            lserver = <<"conference.domain">>,lresource = <<>>},
    to =
        #jid{
            user = <<"8000955974">>,server = <<"domain">>,
            resource = <<"1247573800934835793131555">>,
            luser = <<"8000955974">>,lserver = <<"domain">>,
            lresource = <<"1247573800934835793131555">>},
    sub_els =
        [#xmlel{
             name = <<"query">>,
             attrs =
                 [{<<"xmlns">>,<<"http://jabber.org/protocol/muc#admin">>}],
             children =
                 [#xmlel{
                      name = <<"item">>,
                      attrs =
                          [{<<"jid">>,<<"admin@domain">>},
                           {<<"affiliation">>,<<"owner">>}],
                      children =
                          [#xmlel{
                               name = <<"reason">>,attrs = [],
                               children =
                                   [{xmlcdata,<<"administration">>}]}]}]},
         #stanza_error{
             type = cancel,code = 404,by = <<>>,reason = 'item-not-found',
             text =
                 [#text{
                      lang = <<"en">>,
                      data = <<"Conference room does not exist">>}],
             sub_els = []}],
    meta = #{ip => {0,0,0,0,0,65535,30199,23458}}}

I just tried to enable xml logs and it works, maybe you need to reload page after enabling debug.

About you question: "room created" - I think it's better to create room explicitly first, and invite people only on successful response

I got following XML while creating room.

>> out           
<message xmlns="jabber:client" type="groupchat" to="dummyroom@conference.domain" id="9f464303-4027-4255-9907-0ae9aa6d556f"><active xmlns="http://jabber.org/protocol/chatstates"/></message>
xmppEventHandlers.js:71 << in            
<message xmlns='jabber:client' xml:lang='en' to='8000955972@domain/15376167932381773577169282' from='dummyroom@conference.domain' type='error' id='9f464303-4027-4255-9907-0ae9aa6d556f'><active xmlns='http://jabber.org/protocol/chatstates'/><error code='404' type='cancel'><item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/><text xml:lang='en' xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>Conference room does not exist</text></error></message>

Sure, you should join it first

You should follow XEP-0045 and your xml should look like this. Stanza.io sends it when you call client.joinRoom and then it emits "muc:join" event when you are joined, on("muc:join", ...) is the place where you can start invite people

Yes , self join working now.

Now i am invite member after creating room using this method client.invite(room,opts);
Request also send successfully but i could not get that how to accept that request ?

Following XML i got while invite other user in room

 <iq xmlns="jabber:client" type="set" to="room1@conference.domain" id="b8ae1fa1-191a-4e13-99dd-3ef29e5d4bb7"><query xmlns="urn:xmpp:mam:2" queryid="b8ae1fa1-191a-4e13-99dd-3ef29e5d4bb7"><set xmlns="http://jabber.org/protocol/rsm"><max>40</max><before/></set><x xmlns="jabber:x:data" type="submit"><field var="FORM_TYPE"><value>urn:xmpp:mam:2</value></field><field var="end"><value>2018-05-17T09:11:43.074Z</value></field></x></query></iq>
xmppEventHandlers.js:71 << in            | <iq xmlns='jabber:client' xml:lang='en' to='918787@domain/398720851064208855521605' from='room1@conference.domain' type='error' id='b8ae1fa1-191a-4e13-99dd-3ef29e5d4bb7'><query xmlns='urn:xmpp:mam:2' queryid='b8ae1fa1-191a-4e13-99dd-3ef29e5d4bb7'><set xmlns='http://jabber.org/protocol/rsm'><max>40</max><before/></set><x xmlns='jabber:x:data' type='submit'><field var='FORM_TYPE'><value>urn:xmpp:mam:2</value></field><field var='end'><value>2018-05-17T09:11:43.074Z</value></field></x></query><error code='503' type='cancel'><service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/><text xml:lang='en' xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>The feature requested is not supported by the conference</text></error></iq>

That is not your request, it is history request which kaiwa automatically send on room join event.
To accept other people invites you should handle on("muc:invite", ...) event.
Just look in node_modules/stanza.io/lib/plugins/muc.js, I'm reading it and describing for you :)

:) I am trying to build this feature exactly like contactRequest work in kaiwa while add single contact

@vitalyster Is it possible to create group like whatsapp using this room option ?

@patelvanita360 XEP-0045 MUC rooms will not look like whatsapp, they deliver messages only for online users and remove people on every accidental disconnect.
For simple multiuser groups its better to use XEP-0033 to send messages to people address list

How to display only "joined" rooms ?
Currently all joined and unjoined rooms are showing .

Hello @vitalyster Any Update for my question ?

MUC model have 'joined' property, you can filter me.mucs on that - https://github.com/ForNeVeR/Kaiwa/blob/master/src/js/views/main.js#L46