Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
a95bb5b2
Commit
a95bb5b2
authored
May 20, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor tests so that IQ_ids always contains only XML stanzas
parent
7e515dd4
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
221 additions
and
238 deletions
+221
-238
spec/controlbox.js
spec/controlbox.js
+13
-13
spec/disco.js
spec/disco.js
+4
-4
spec/http-file-upload.js
spec/http-file-upload.js
+29
-32
spec/muc.js
spec/muc.js
+56
-64
spec/omemo.js
spec/omemo.js
+65
-65
spec/push.js
spec/push.js
+13
-16
spec/room_registration.js
spec/room_registration.js
+16
-20
spec/roomslist.js
spec/roomslist.js
+3
-3
spec/roster.js
spec/roster.js
+10
-12
tests/mock.js
tests/mock.js
+3
-0
tests/utils.js
tests/utils.js
+9
-9
No files found.
spec/controlbox.js
View file @
a95bb5b2
...
...
@@ -6,7 +6,8 @@
$msg
=
converse
.
env
.
$msg
,
$iq
=
converse
.
env
.
$iq
,
u
=
converse
.
env
.
utils
,
Strophe
=
converse
.
env
.
Strophe
;
Strophe
=
converse
.
env
.
Strophe
,
sizzle
=
converse
.
env
.
sizzle
;
describe
(
"
The Controlbox
"
,
function
()
{
...
...
@@ -232,27 +233,26 @@
expect
(
modal
.
name_auto_complete
).
toBe
(
undefined
);
await
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
1000
);
const
sendIQ
=
_converse
.
connection
.
sendIQ
;
let
sent_stanza
;
spyOn
(
_converse
.
connection
,
'
sendIQ
'
).
and
.
callFake
(
function
(
iq
,
callback
,
errback
)
{
sent_stanza
=
iq
;
sendIQ
.
bind
(
this
)(
iq
,
callback
,
errback
);
});
expect
(
!
_
.
isNull
(
modal
.
el
.
querySelector
(
'
form.add-xmpp-contact
'
))).
toBeTruthy
();
const
input_jid
=
modal
.
el
.
querySelector
(
'
input[name="jid"]
'
);
const
input_name
=
modal
.
el
.
querySelector
(
'
input[name="name"]
'
);
input_jid
.
value
=
'
someone@localhost
'
;
modal
.
el
.
querySelector
(
'
button[type="submit"]
'
).
click
();
await
test_utils
.
waitUntil
(()
=>
sent_stanza
.
nodeTree
.
matches
(
'
iq
'
));
expect
(
sent_stanza
.
toLocaleString
()).
toEqual
(
`<iq id="
${
sent_stanza
.
nodeTree
.
getAttribute
(
'
id
'
)}
" type="set" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:roster"><item jid="someone@localhost"/></query>`
+
`</iq>`
);
const
IQ_stanzas
=
_converse
.
connection
.
IQ_stanzas
;
const
sent_stanza
=
await
test_utils
.
waitUntil
(
()
=>
IQ_stanzas
.
filter
(
s
=>
sizzle
(
`query[xmlns="
${
Strophe
.
NS
.
ROSTER
}
"]`
,
s
).
length
).
pop
()
);
expect
(
Strophe
.
serialize
(
sent_stanza
)).
toEqual
(
`<iq id="
${
sent_stanza
.
getAttribute
(
'
id
'
)}
" type="set" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:roster"><item jid="someone@localhost"/></query>`
+
`</iq>`
);
done
();
}));
it
(
"
integrates with xhr_user_search_url to search for contacts
"
,
it
(
"
integrates with xhr_user_search_url to search for contacts
"
,
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{
'
xhr_user_search_url
'
:
'
http://example.org/?
'
},
...
...
spec/disco.js
View file @
a95bb5b2
...
...
@@ -22,7 +22,7 @@
const
IQ_ids
=
_converse
.
connection
.
IQ_ids
;
test_utils
.
waitUntil
(
function
()
{
return
_
.
filter
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
nodeTree
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
return
iq
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
}).
length
>
0
;
},
300
).
then
(
function
()
{
/* <iq type='result'
...
...
@@ -52,7 +52,7 @@
* </iq>
*/
var
stanza
=
_
.
find
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
nodeTree
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
return
iq
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
});
var
info_IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
stanza
=
$iq
({
...
...
@@ -101,7 +101,7 @@
// Converse.js sees that the entity has a disco#items feature,
// so it will make a query for it.
return
_
.
filter
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
nodeTree
.
querySelector
(
'
query[xmlns="http://jabber.org/protocol/disco#items"]
'
);
return
iq
.
querySelector
(
'
query[xmlns="http://jabber.org/protocol/disco#items"]
'
);
}).
length
>
0
;
},
300
).
then
(
function
()
{
/* <iq type='result'
...
...
@@ -131,7 +131,7 @@
* </iq>
*/
var
stanza
=
_
.
find
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
nodeTree
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#items"]
'
);
return
iq
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#items"]
'
);
});
var
items_IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
stanza
=
$iq
({
...
...
spec/http-file-upload.js
View file @
a95bb5b2
This diff is collapsed.
Click to expand it.
spec/muc.js
View file @
a95bb5b2
This diff is collapsed.
Click to expand it.
spec/omemo.js
View file @
a95bb5b2
This diff is collapsed.
Click to expand it.
spec/push.js
View file @
a95bb5b2
...
...
@@ -29,11 +29,10 @@
_converse
.
bare_jid
,
[{
'
category
'
:
'
account
'
,
'
type
'
:
'
registered
'
}],
[
'
urn:xmpp:push:0
'
],
[],
'
info
'
);
const
node
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
'
iq[type="set"] enable[xmlns="urn:xmpp:push:0"]
'
)).
pop
()
const
stanza
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
querySelector
(
'
iq[type="set"] enable[xmlns="urn:xmpp:push:0"]
'
)).
pop
()
);
const
stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
()).
toEqual
(
expect
(
Strophe
.
serialize
(
stanza
)).
toEqual
(
`<iq id="
${
stanza
.
getAttribute
(
'
id
'
)}
" type="set" xmlns="jabber:client">`
+
'
<enable jid="push-5@client.example" node="yxs32uqsflafdk3iuqo" xmlns="urn:xmpp:push:0"/>
'
+
'
</iq>
'
...
...
@@ -71,17 +70,17 @@
[{
'
category
'
:
'
account
'
,
'
type
'
:
'
registered
'
}],
[
'
urn:xmpp:push:0
'
],
[],
'
info
'
);
const
stanza
=
await
test_utils
.
waitUntil
(
()
=>
_
.
filter
(
IQ_stanzas
,
(
iq
)
=>
iq
.
nodeTree
.
querySelector
(
'
iq[type="set"] enable[xmlns="urn:xmpp:push:0"]
'
)).
pop
()
()
=>
_
.
filter
(
IQ_stanzas
,
(
iq
)
=>
iq
.
querySelector
(
'
iq[type="set"] enable[xmlns="urn:xmpp:push:0"]
'
)).
pop
()
);
expect
(
stanza
.
toLocaleString
(
)).
toEqual
(
`<iq id="
${
stanza
.
nodeTree
.
getAttribute
(
'
id
'
)}
" to="chat.shakespeare.lit" type="set" xmlns="jabber:client">`
+
expect
(
Strophe
.
serialize
(
stanza
)).
toEqual
(
`<iq id="
${
stanza
.
getAttribute
(
'
id
'
)}
" to="chat.shakespeare.lit" type="set" xmlns="jabber:client">`
+
'
<enable jid="push-5@client.example" node="yxs32uqsflafdk3iuqo" xmlns="urn:xmpp:push:0"/>
'
+
'
</iq>
'
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
$iq
({
'
to
'
:
_converse
.
connection
.
jid
,
'
type
'
:
'
result
'
,
'
id
'
:
stanza
.
nodeTree
.
getAttribute
(
'
id
'
)
'
id
'
:
stanza
.
getAttribute
(
'
id
'
)
})));
await
test_utils
.
waitUntil
(()
=>
_
.
includes
(
_converse
.
session
.
get
(
'
push_enabled
'
),
'
chat.shakespeare.lit
'
));
done
();
...
...
@@ -105,11 +104,10 @@
_converse
.
bare_jid
,
[{
'
category
'
:
'
account
'
,
'
type
'
:
'
registered
'
}],
[
'
urn:xmpp:push:0
'
],
[],
'
info
'
);
const
node
=
await
test_utils
.
waitUntil
(
()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
'
iq[type="set"] disable[xmlns="urn:xmpp:push:0"]
'
)).
pop
()
const
stanza
=
await
test_utils
.
waitUntil
(
()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
querySelector
(
'
iq[type="set"] disable[xmlns="urn:xmpp:push:0"]
'
)).
pop
()
);
const
stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
()).
toEqual
(
expect
(
Strophe
.
serialize
(
stanza
)).
toEqual
(
`<iq id="
${
stanza
.
getAttribute
(
'
id
'
)}
" type="set" xmlns="jabber:client">`
+
'
<disable jid="push-5@client.example" node="yxs32uqsflafdk3iuqo" xmlns="urn:xmpp:push:0"/>
'
+
'
</iq>
'
...
...
@@ -147,11 +145,10 @@
[{
'
category
'
:
'
account
'
,
'
type
'
:
'
registered
'
}],
[
'
urn:xmpp:push:0
'
],
[],
'
info
'
);
const
node
=
await
test_utils
.
waitUntil
(
()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
'
iq[type="set"] enable[xmlns="urn:xmpp:push:0"]
'
)).
pop
()
const
stanza
=
await
test_utils
.
waitUntil
(
()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
querySelector
(
'
iq[type="set"] enable[xmlns="urn:xmpp:push:0"]
'
)).
pop
()
);
const
stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
()).
toEqual
(
expect
(
Strophe
.
serialize
(
stanza
)).
toEqual
(
`<iq id="
${
stanza
.
getAttribute
(
'
id
'
)}
" type="set" xmlns="jabber:client">`
+
'
<enable jid="push-5@client.example" node="yxs32uqsflafdk3iuqo" xmlns="urn:xmpp:push:0">
'
+
'
<x type="submit" xmlns="jabber:x:data">
'
+
...
...
spec/room_registration.js
View file @
a95bb5b2
...
...
@@ -32,11 +32,10 @@
});
return
test_utils
.
waitUntil
(()
=>
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
iq
=>
sizzle
(
`iq[to="coven@chat.shakespeare.lit"][type="get"] query[xmlns="jabber:iq:register"]`
,
iq
.
nodeTree
).
length
iq
=>
sizzle
(
`iq[to="coven@chat.shakespeare.lit"][type="get"] query[xmlns="jabber:iq:register"]`
,
iq
).
length
).
pop
());
}).
then
(
node
=>
{
const
stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
())
}).
then
(
stanza
=>
{
expect
(
Strophe
.
serialize
(
stanza
))
.
toBe
(
`<iq from="dummy@localhost/resource" id="
${
stanza
.
getAttribute
(
'
id
'
)}
" to="coven@chat.shakespeare.lit" `
+
`type="get" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:register"/></iq>`
);
...
...
@@ -56,11 +55,10 @@
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
result
));
return
test_utils
.
waitUntil
(()
=>
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
iq
=>
sizzle
(
`iq[to="coven@chat.shakespeare.lit"][type="set"] query[xmlns="jabber:iq:register"]`
,
iq
.
nodeTree
).
length
iq
=>
sizzle
(
`iq[to="coven@chat.shakespeare.lit"][type="set"] query[xmlns="jabber:iq:register"]`
,
iq
).
length
).
pop
());
}).
then
(
node
=>
{
const
stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
()).
toBe
(
}).
then
(
stanza
=>
{
expect
(
Strophe
.
serialize
(
stanza
)).
toBe
(
`<iq from="dummy@localhost/resource" id="
${
stanza
.
getAttribute
(
'
id
'
)}
" to="coven@chat.shakespeare.lit" type="set" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:register">`
+
`<x type="submit" xmlns="jabber:x:data">`
+
...
...
@@ -83,15 +81,15 @@
function
(
done
,
_converse
)
{
let
view
;
const
IQ_stanzas
=
_converse
.
connection
.
IQ_stanzas
;
const
IQ_stanzas
=
_converse
.
connection
.
IQ_stanzas
;
const
room_jid
=
'
coven@chat.shakespeare.lit
'
;
_converse
.
api
.
rooms
.
open
(
room_jid
,
{
'
nick
'
:
'
romeo
'
})
.
then
(()
=>
{
return
test_utils
.
waitUntil
(()
=>
_
.
get
(
_
.
filter
(
return
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
iq
=>
iq
.
querySelector
(
`iq[to="
${
room_jid
}
"] query[xmlns="http://jabber.org/protocol/disco#info"]`
)).
pop
()
,
'
nodeTree
'
)
);
)).
pop
());
}).
then
(
stanza
=>
{
const
features_stanza
=
$iq
({
'
from
'
:
room_jid
,
...
...
@@ -127,11 +125,10 @@
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
return
test_utils
.
waitUntil
(()
=>
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
iq
=>
sizzle
(
`iq[to="coven@chat.shakespeare.lit"][type="get"] query[xmlns="jabber:iq:register"]`
,
iq
.
nodeTree
).
length
iq
=>
sizzle
(
`iq[to="coven@chat.shakespeare.lit"][type="get"] query[xmlns="jabber:iq:register"]`
,
iq
).
length
).
pop
());
}).
then
(
node
=>
{
const
stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
())
}).
then
(
stanza
=>
{
expect
(
Strophe
.
serialize
(
stanza
))
.
toBe
(
`<iq from="dummy@localhost/resource" id="
${
stanza
.
getAttribute
(
'
id
'
)}
" to="coven@chat.shakespeare.lit" `
+
`type="get" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:register"/></iq>`
);
...
...
@@ -151,11 +148,10 @@
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
result
));
return
test_utils
.
waitUntil
(()
=>
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
iq
=>
sizzle
(
`iq[to="coven@chat.shakespeare.lit"][type="set"] query[xmlns="jabber:iq:register"]`
,
iq
.
nodeTree
).
length
iq
=>
sizzle
(
`iq[to="coven@chat.shakespeare.lit"][type="set"] query[xmlns="jabber:iq:register"]`
,
iq
).
length
).
pop
());
}).
then
(
node
=>
{
const
stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
()).
toBe
(
}).
then
(
stanza
=>
{
expect
(
Strophe
.
serialize
(
stanza
)).
toBe
(
`<iq from="dummy@localhost/resource" id="
${
stanza
.
getAttribute
(
'
id
'
)}
" to="coven@chat.shakespeare.lit" type="set" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:register">`
+
`<x type="submit" xmlns="jabber:x:data">`
+
...
...
spec/roomslist.js
View file @
a95bb5b2
...
...
@@ -153,11 +153,11 @@
const
room_jid
=
'
coven@chat.shakespeare.lit
'
;
test_utils
.
openControlBox
();
await
_converse
.
api
.
rooms
.
open
(
room_jid
,
{
'
nick
'
:
'
some1
'
});
const
last_stanza
=
await
test_utils
.
waitUntil
(()
=>
_
.
get
(
_
.
filter
(
const
last_stanza
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
iq
=>
iq
.
querySelector
(
`iq[to="
${
room_jid
}
"] query[xmlns="http://jabber.org/protocol/disco#info"]`
)).
pop
()
,
'
nodeTree
'
)
);
)).
pop
());
const
view
=
_converse
.
chatboxviews
.
get
(
room_jid
);
const
IQ_id
=
last_stanza
.
getAttribute
(
'
id
'
);
const
features_stanza
=
$iq
({
...
...
spec/roster.js
View file @
a95bb5b2
...
...
@@ -37,18 +37,18 @@
spyOn
(
_converse
.
api
,
"
trigger
"
).
and
.
callThrough
();
const
IQs
=
_converse
.
connection
.
IQ_stanzas
;
const
node
=
await
test_utils
.
waitUntil
(
()
=>
_
.
filter
(
IQs
,
iq
=>
iq
.
nodeTree
.
querySelector
(
'
iq query[xmlns="jabber:iq:roster"]
'
)).
pop
());
const
stanza
=
await
test_utils
.
waitUntil
(
()
=>
_
.
filter
(
IQs
,
iq
=>
iq
.
querySelector
(
'
iq query[xmlns="jabber:iq:roster"]
'
)).
pop
());
expect
(
_converse
.
api
.
trigger
.
calls
.
all
().
map
(
c
=>
c
.
args
[
0
]).
includes
(
'
rosterContactsFetched
'
)).
toBeFalsy
();
expect
(
node
.
toLocaleString
(
)).
toBe
(
`<iq id="
${
node
.
nodeTree
.
getAttribute
(
'
id
'
)}
" type="get" xmlns="jabber:client">`
+
expect
(
Strophe
.
serialize
(
stanza
)).
toBe
(
`<iq id="
${
stanza
.
getAttribute
(
'
id
'
)}
" type="get" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:roster"/>`
+
`</iq>`
);
const
result
=
$iq
({
'
to
'
:
_converse
.
connection
.
jid
,
'
type
'
:
'
result
'
,
'
id
'
:
node
.
nodeTree
.
getAttribute
(
'
id
'
)
'
id
'
:
stanza
.
getAttribute
(
'
id
'
)
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
jabber:iq:roster
'
}).
c
(
'
item
'
,
{
'
jid
'
:
'
nurse@example.com
'
}).
up
()
...
...
@@ -64,12 +64,11 @@
async
function
(
done
,
_converse
)
{
const
IQ_stanzas
=
_converse
.
connection
.
IQ_stanzas
;
let
node
=
await
test_utils
.
waitUntil
(
()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
'
iq query[xmlns="jabber:iq:roster"]
'
)).
pop
()
let
stanza
=
await
test_utils
.
waitUntil
(
()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
querySelector
(
'
iq query[xmlns="jabber:iq:roster"]
'
)).
pop
()
);
let
stanza
=
node
.
nodeTree
;
expect
(
_converse
.
roster
.
data
.
get
(
'
version
'
)).
toBeUndefined
();
expect
(
node
.
toLocaleString
(
)).
toBe
(
expect
(
Strophe
.
serialize
(
stanza
)).
toBe
(
`<iq id="
${
stanza
.
getAttribute
(
'
id
'
)}
" type="get" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:roster"/>`
+
`</iq>`
);
...
...
@@ -89,9 +88,8 @@
expect
(
_converse
.
roster
.
models
.
length
).
toBe
(
2
);
_converse
.
roster
.
fetchFromServer
();
node
=
_converse
.
connection
.
IQ_stanzas
.
pop
();
stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
()).
toBe
(
stanza
=
_converse
.
connection
.
IQ_stanzas
.
pop
();
expect
(
Strophe
.
serialize
(
stanza
)).
toBe
(
`<iq id="
${
stanza
.
getAttribute
(
'
id
'
)}
" type="get" xmlns="jabber:client">`
+
`<query ver="ver7" xmlns="jabber:iq:roster"/>`
+
`</iq>`
);
...
...
tests/mock.js
View file @
a95bb5b2
...
...
@@ -117,6 +117,9 @@
c
.
IQ_stanzas
=
[];
c
.
IQ_ids
=
[];
c
.
sendIQ
=
function
(
iq
,
callback
,
errback
)
{
if
(
!
_
.
isElement
(
iq
))
{
iq
=
iq
.
nodeTree
;
}
this
.
IQ_stanzas
.
push
(
iq
);
const
id
=
sendIQ
.
bind
(
this
)(
iq
,
callback
,
errback
);
this
.
IQ_ids
.
push
(
id
);
...
...
tests/utils.js
View file @
a95bb5b2
...
...
@@ -19,14 +19,14 @@
const
iq
=
await
utils
.
waitUntil
(()
=>
{
return
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
(
iq
)
=>
sizzle
(
`iq[to="
${
entity_jid
}
"] query[xmlns="http://jabber.org/protocol/disco#
${
type
}
"]`
,
iq
.
nodeTree
).
length
(
iq
)
=>
sizzle
(
`iq[to="
${
entity_jid
}
"] query[xmlns="http://jabber.org/protocol/disco#
${
type
}
"]`
,
iq
).
length
).
pop
();
},
300
);
const
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
from
'
:
entity_jid
,
'
to
'
:
'
dummy@localhost/resource
'
,
'
id
'
:
iq
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq
.
getAttribute
(
'
id
'
),
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#
'
+
type
});
_
.
forEach
(
identities
,
function
(
identity
)
{
...
...
@@ -123,11 +123,11 @@
const
stanzas
=
_converse
.
connection
.
IQ_stanzas
;
await
_converse
.
api
.
rooms
.
open
(
room_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
room_jid
);
let
stanza
=
await
utils
.
waitUntil
(()
=>
_
.
get
(
_
.
filter
(
let
stanza
=
await
utils
.
waitUntil
(()
=>
_
.
filter
(
stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
iq
=>
iq
.
querySelector
(
`iq[to="
${
room_jid
}
"] query[xmlns="http://jabber.org/protocol/disco#info"]`
)).
pop
()
,
'
nodeTree
'
)
);
)).
pop
());
const
features_stanza
=
$iq
({
'
from
'
:
room_jid
,
...
...
@@ -164,14 +164,14 @@
const
iq
=
await
utils
.
waitUntil
(()
=>
_
.
filter
(
stanzas
,
s
=>
sizzle
(
`iq[to="
${
room_jid
}
"] query[node="x-roomuser-item"]`
,
s
.
nodeTree
).
length
s
=>
sizzle
(
`iq[to="
${
room_jid
}
"] query[node="x-roomuser-item"]`
,
s
).
length
).
pop
());
// We remove the stanza, otherwise we might get stale stanzas returned in our filter above.
stanzas
.
splice
(
stanzas
.
indexOf
(
iq
),
1
)
// The XMPP server returns the reserved nick for this user.
const
IQ_id
=
iq
.
nodeTree
.
getAttribute
(
'
id
'
);
const
IQ_id
=
iq
.
getAttribute
(
'
id
'
);
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
id
'
:
IQ_id
,
...
...
@@ -266,13 +266,13 @@
const
iq
=
await
utils
.
waitUntil
(()
=>
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
iq
=>
sizzle
(
`iq[type="get"] query[xmlns="
${
Strophe
.
NS
.
ROSTER
}
"]`
,
iq
.
nodeTree
).
length
iq
=>
sizzle
(
`iq[type="get"] query[xmlns="
${
Strophe
.
NS
.
ROSTER
}
"]`
,
iq
).
length
).
pop
());
const
result
=
$iq
({
'
to
'
:
_converse
.
connection
.
jid
,
'
type
'
:
'
result
'
,
'
id
'
:
iq
.
nodeTree
.
getAttribute
(
'
id
'
)
'
id
'
:
iq
.
getAttribute
(
'
id
'
)
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
jabber:iq:roster
'
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment