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
e053b970
Commit
e053b970
authored
May 28, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set room `connection_status' to DISCONNECTED...
when receiving an `unavailable` presence for ourselves.
parent
85c4d144
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
50 deletions
+60
-50
spec/muc.js
spec/muc.js
+3
-0
src/headless/converse-muc.js
src/headless/converse-muc.js
+57
-50
No files found.
spec/muc.js
View file @
e053b970
...
@@ -2138,6 +2138,7 @@
...
@@ -2138,6 +2138,7 @@
const
__
=
_converse
.
__
;
const
__
=
_converse
.
__
;
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
oldnick
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
oldnick
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
expect
(
view
.
model
.
get
(
'
connection_status
'
)).
toBe
(
converse
.
ROOMSTATUS
.
ENTERED
);
const
chat_content
=
view
.
el
.
querySelector
(
'
.chat-content
'
);
const
chat_content
=
view
.
el
.
querySelector
(
'
.chat-content
'
);
let
occupants
=
view
.
el
.
querySelector
(
'
.occupant-list
'
);
let
occupants
=
view
.
el
.
querySelector
(
'
.occupant-list
'
);
...
@@ -2169,6 +2170,7 @@
...
@@ -2169,6 +2170,7 @@
expect
(
sizzle
(
'
div.chat-info:last
'
).
pop
().
textContent
).
toBe
(
expect
(
sizzle
(
'
div.chat-info:last
'
).
pop
().
textContent
).
toBe
(
__
(
_converse
.
muc
.
new_nickname_messages
[
"
303
"
],
"
newnick
"
)
__
(
_converse
.
muc
.
new_nickname_messages
[
"
303
"
],
"
newnick
"
)
);
);
expect
(
view
.
model
.
get
(
'
connection_status
'
)).
toBe
(
converse
.
ROOMSTATUS
.
DISCONNECTED
);
occupants
=
view
.
el
.
querySelector
(
'
.occupant-list
'
);
occupants
=
view
.
el
.
querySelector
(
'
.occupant-list
'
);
expect
(
occupants
.
childNodes
.
length
).
toBe
(
1
);
expect
(
occupants
.
childNodes
.
length
).
toBe
(
1
);
...
@@ -2187,6 +2189,7 @@
...
@@ -2187,6 +2189,7 @@
.
c
(
'
status
'
).
attrs
({
code
:
'
110
'
}).
nodeTree
;
.
c
(
'
status
'
).
attrs
({
code
:
'
110
'
}).
nodeTree
;
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
expect
(
view
.
model
.
get
(
'
connection_status
'
)).
toBe
(
converse
.
ROOMSTATUS
.
ENTERED
);
// XXX: currently we still have an additional "has entered the groupchat"
// XXX: currently we still have an additional "has entered the groupchat"
// notification for the new nickname. Ideally we'd not have
// notification for the new nickname. Ideally we'd not have
// that, but that's probably not possible without some
// that, but that's probably not possible without some
...
...
src/headless/converse-muc.js
View file @
e053b970
...
@@ -1281,30 +1281,33 @@ converse.plugins.add('converse-muc', {
...
@@ -1281,30 +1281,33 @@ converse.plugins.add('converse-muc', {
_converse
.
api
.
trigger
(
'
message
'
,
{
'
stanza
'
:
original_stanza
,
'
chatbox
'
:
this
});
_converse
.
api
.
trigger
(
'
message
'
,
{
'
stanza
'
:
original_stanza
,
'
chatbox
'
:
this
});
},
},
onErrorPresence
(
pres
)
{
// TODO: currently showErrorMessageFromPresence handles
// 'error" presences in converse-muc-views.
// Instead, they should be handled here and the presence
// handler removed from there.
if
(
sizzle
(
`error not-authorized[xmlns="
${
Strophe
.
NS
.
STANZAS
}
"]`
,
pres
).
length
)
{
this
.
save
(
'
connection_status
'
,
converse
.
ROOMSTATUS
.
PASSWORD_REQUIRED
);
}
else
{
this
.
save
(
'
connection_status
'
,
converse
.
ROOMSTATUS
.
DISCONNECTED
);
}
},
/**
/**
* Handles all MUC presence stanzas.
* Handles all MUC presence stanzas.
* @private
* @private
* @method _converse.ChatRoom#onPresence
* @method _converse.ChatRoom#onPresence
* @param { XMLElement }
pres - The
stanza
* @param { XMLElement } stanza
*/
*/
onPresence
(
pres
)
{
onPresence
(
stanza
)
{
if
(
pres
.
getAttribute
(
'
type
'
)
===
'
error
'
)
{
if
(
stanza
.
getAttribute
(
'
type
'
)
===
'
error
'
)
{
// TODO: currently showErrorMessageFromPresence handles
return
this
.
onErrorPresence
(
stanza
);
// 'error" presences in converse-muc-views.
// Instead, they should be handled here and the presence
// handler removed from there.
if
(
sizzle
(
`error not-authorized[xmlns="
${
Strophe
.
NS
.
STANZAS
}
"]`
,
pres
).
length
)
{
this
.
save
(
'
connection_status
'
,
converse
.
ROOMSTATUS
.
PASSWORD_REQUIRED
);
}
else
{
this
.
save
(
'
connection_status
'
,
converse
.
ROOMSTATUS
.
DISCONNECTED
);
}
return
;
}
}
const
is_self
=
pres
.
querySelector
(
"
status[code='110']
"
);
if
(
stanza
.
querySelector
(
"
status[code='110']
"
))
{
if
(
is_self
&&
pres
.
getAttribute
(
'
type
'
)
!==
'
unavailable
'
)
{
this
.
onOwnPresence
(
stanza
);
this
.
onOwnPresence
(
pres
);
}
}
this
.
updateOccupantsOnPresence
(
pres
);
this
.
updateOccupantsOnPresence
(
stanza
);
if
(
this
.
get
(
'
role
'
)
!==
'
none
'
&&
this
.
get
(
'
connection_status
'
)
===
converse
.
ROOMSTATUS
.
CONNECTING
)
{
if
(
this
.
get
(
'
role
'
)
!==
'
none
'
&&
this
.
get
(
'
connection_status
'
)
===
converse
.
ROOMSTATUS
.
CONNECTING
)
{
this
.
save
(
'
connection_status
'
,
converse
.
ROOMSTATUS
.
CONNECTED
);
this
.
save
(
'
connection_status
'
,
converse
.
ROOMSTATUS
.
CONNECTED
);
}
}
...
@@ -1325,41 +1328,45 @@ converse.plugins.add('converse-muc', {
...
@@ -1325,41 +1328,45 @@ converse.plugins.add('converse-muc', {
* @method _converse.ChatRoom#onOwnPresence
* @method _converse.ChatRoom#onOwnPresence
* @param { XMLElement } pres - The stanza
* @param { XMLElement } pres - The stanza
*/
*/
onOwnPresence
(
pres
)
{
onOwnPresence
(
stanza
)
{
this
.
saveAffiliationAndRole
(
pres
);
this
.
saveAffiliationAndRole
(
stanza
);
const
locked_room
=
pres
.
querySelector
(
"
status[code='201']
"
);
if
(
stanza
.
getAttribute
(
'
type
'
)
===
'
unavailable
'
)
{
if
(
locked_room
)
{
this
.
save
(
'
connection_status
'
,
converse
.
ROOMSTATUS
.
DISCONNECTED
);
if
(
this
.
get
(
'
auto_configure
'
))
{
}
else
{
this
.
autoConfigureChatRoom
().
then
(()
=>
this
.
refreshRoomFeatures
());
const
locked_room
=
stanza
.
querySelector
(
"
status[code='201']
"
);
}
else
if
(
_converse
.
muc_instant_rooms
)
{
if
(
locked_room
)
{
// Accept default configuration
if
(
this
.
get
(
'
auto_configure
'
))
{
this
.
saveConfiguration
().
then
(()
=>
this
.
refreshRoomFeatures
());
this
.
autoConfigureChatRoom
().
then
(()
=>
this
.
refreshRoomFeatures
());
}
else
{
}
else
if
(
_converse
.
muc_instant_rooms
)
{
/**
// Accept default configuration
* Triggered when a new room has been created which first needs to be configured
this
.
saveConfiguration
().
then
(()
=>
this
.
refreshRoomFeatures
());
* and when `auto_configure` is set to `false`.
}
else
{
* Used by `_converse.ChatRoomView` in order to know when to render the
/**
* configuration form for a new room.
* Triggered when a new room has been created which first needs to be configured
* @event _converse.ChatRoom#configurationNeeded
* and when `auto_configure` is set to `false`.
* @example _converse.api.listen.on('configurationNeeded', () => { ... });
* Used by `_converse.ChatRoomView` in order to know when to render the
*/
* configuration form for a new room.
this
.
trigger
(
'
configurationNeeded
'
);
* @event _converse.ChatRoom#configurationNeeded
return
;
// We haven't yet entered the groupchat, so bail here.
* @example _converse.api.listen.on('configurationNeeded', () => { ... });
}
*/
}
else
if
(
!
this
.
features
.
get
(
'
fetched
'
))
{
this
.
trigger
(
'
configurationNeeded
'
);
// The features for this groupchat weren't fetched.
return
;
// We haven't yet entered the groupchat, so bail here.
// That must mean it's a new groupchat without locking
}
// (in which case Prosody doesn't send a 201 status),
}
else
if
(
!
this
.
features
.
get
(
'
fetched
'
))
{
// otherwise the features would have been fetched in
// The features for this groupchat weren't fetched.
// the "initialize" method already.
// That must mean it's a new groupchat without locking
if
(
this
.
get
(
'
affiliation
'
)
===
'
owner
'
&&
this
.
get
(
'
auto_configure
'
))
{
// (in which case Prosody doesn't send a 201 status),
this
.
autoConfigureChatRoom
().
then
(()
=>
this
.
refreshRoomFeatures
());
// otherwise the features would have been fetched in
}
else
{
// the "initialize" method already.
this
.
getRoomFeatures
();
if
(
this
.
get
(
'
affiliation
'
)
===
'
owner
'
&&
this
.
get
(
'
auto_configure
'
))
{
this
.
autoConfigureChatRoom
().
then
(()
=>
this
.
refreshRoomFeatures
());
}
else
{
this
.
getRoomFeatures
();
}
}
}
this
.
save
(
'
connection_status
'
,
converse
.
ROOMSTATUS
.
ENTERED
);
}
}
this
.
save
(
'
connection_status
'
,
converse
.
ROOMSTATUS
.
ENTERED
);
},
},
/**
/**
...
...
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