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
78c7ded2
Commit
78c7ded2
authored
Aug 05, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
converse-disco: Catch and report errors that happen during tests
parent
021143d6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
src/headless/converse-disco.js
src/headless/converse-disco.js
+25
-0
No files found.
src/headless/converse-disco.js
View file @
78c7ded2
...
@@ -410,6 +410,12 @@ converse.plugins.add('converse-disco', {
...
@@ -410,6 +410,12 @@ converse.plugins.add('converse-disco', {
if
(
_
.
isNil
(
name
)
||
_
.
isNil
(
xmlns
))
{
if
(
_
.
isNil
(
name
)
||
_
.
isNil
(
xmlns
))
{
throw
new
Error
(
"
name and xmlns need to be provided when calling disco.stream.getFeature
"
);
throw
new
Error
(
"
name and xmlns need to be provided when calling disco.stream.getFeature
"
);
}
}
if
(
_converse
.
stream_features
===
undefined
&&
!
_converse
.
api
.
connection
.
connected
())
{
// Happens during tests when disco lookups happen asynchronously after teardown.
const
msg
=
`Tried to get feature
${
name
}
${
xmlns
}
but _converse.stream_features has been torn down`
;
_converse
.
log
(
msg
,
Strophe
.
LogLevel
.
WARN
);
return
;
}
return
_converse
.
stream_features
.
findWhere
({
'
name
'
:
name
,
'
xmlns
'
:
xmlns
});
return
_converse
.
stream_features
.
findWhere
({
'
name
'
:
name
,
'
xmlns
'
:
xmlns
});
}
}
},
},
...
@@ -564,6 +570,12 @@ converse.plugins.add('converse-disco', {
...
@@ -564,6 +570,12 @@ converse.plugins.add('converse-disco', {
if
(
_
.
isNil
(
jid
))
{
if
(
_
.
isNil
(
jid
))
{
return
_converse
.
disco_entities
;
return
_converse
.
disco_entities
;
}
}
if
(
_converse
.
disco_entities
===
undefined
&&
!
_converse
.
api
.
connection
.
connected
())
{
// Happens during tests when disco lookups happen asynchronously after teardown.
const
msg
=
`Tried to look up entity
${
jid
}
but _converse.disco_entities has been torn down`
;
_converse
.
log
(
msg
,
Strophe
.
LogLevel
.
WARN
);
return
;
}
const
entity
=
_converse
.
disco_entities
.
get
(
jid
);
const
entity
=
_converse
.
disco_entities
.
get
(
jid
);
if
(
entity
||
!
create
)
{
if
(
entity
||
!
create
)
{
return
entity
;
return
entity
;
...
@@ -619,6 +631,13 @@ converse.plugins.add('converse-disco', {
...
@@ -619,6 +631,13 @@ converse.plugins.add('converse-disco', {
}
}
await
_converse
.
api
.
waitUntil
(
'
discoInitialized
'
);
await
_converse
.
api
.
waitUntil
(
'
discoInitialized
'
);
let
entity
=
await
_converse
.
api
.
disco
.
entities
.
get
(
jid
,
true
);
let
entity
=
await
_converse
.
api
.
disco
.
entities
.
get
(
jid
,
true
);
if
(
_converse
.
disco_entities
===
undefined
&&
!
_converse
.
api
.
connection
.
connected
())
{
// Happens during tests when disco lookups happen asynchronously after teardown.
const
msg
=
`Tried to get feature
${
feature
}
for
${
jid
}
but _converse.disco_entities has been torn down`
;
_converse
.
log
(
msg
,
Strophe
.
LogLevel
.
WARN
);
return
;
}
entity
=
await
entity
.
waitUntilFeaturesDiscovered
;
entity
=
await
entity
.
waitUntilFeaturesDiscovered
;
const
promises
=
_
.
concat
(
const
promises
=
_
.
concat
(
entity
.
items
.
map
(
item
=>
item
.
hasFeature
(
feature
)),
entity
.
items
.
map
(
item
=>
item
.
hasFeature
(
feature
)),
...
@@ -756,6 +775,12 @@ converse.plugins.add('converse-disco', {
...
@@ -756,6 +775,12 @@ converse.plugins.add('converse-disco', {
*/
*/
async
getIdentity
(
category
,
type
,
jid
)
{
async
getIdentity
(
category
,
type
,
jid
)
{
const
e
=
await
_converse
.
api
.
disco
.
entities
.
get
(
jid
,
true
);
const
e
=
await
_converse
.
api
.
disco
.
entities
.
get
(
jid
,
true
);
if
(
e
===
undefined
&&
!
_converse
.
api
.
connection
.
connected
())
{
// Happens during tests when disco lookups happen asynchronously after teardown.
const
msg
=
`Tried to look up category
${
category
}
for
${
jid
}
but _converse.disco_entities has been torn down`
;
_converse
.
log
(
msg
,
Strophe
.
LogLevel
.
WARN
);
return
;
}
return
e
.
getIdentity
(
category
,
type
);
return
e
.
getIdentity
(
category
,
type
);
}
}
}
}
...
...
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