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
dc169304
Commit
dc169304
authored
Dec 14, 2017
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test the /voice command and fix a bug
parent
5eabf400
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
6 deletions
+61
-6
spec/chatroom.js
spec/chatroom.js
+38
-1
src/converse-muc.js
src/converse-muc.js
+23
-5
No files found.
spec/chatroom.js
View file @
dc169304
...
...
@@ -1977,7 +1977,7 @@
});
}));
it
(
"
/mute
to
mute a user
"
,
it
(
"
/mute
and /voice to mute and un
mute a user
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
...
...
@@ -2069,6 +2069,43 @@
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
info_msgs
=
Array
.
prototype
.
slice
.
call
(
view
.
el
.
querySelectorAll
(
'
.chat-info
'
),
0
);
expect
(
info_msgs
.
pop
().
textContent
).
toBe
(
"
annoyingGuy has been muted.
"
);
view
.
onMessageSubmitted
(
'
/voice annoyingGuy Now you can talk again
'
);
expect
(
view
.
validateRoleChangeCommand
.
calls
.
count
()).
toBe
(
3
);
expect
(
view
.
showStatusNotification
.
calls
.
count
()).
toBe
(
2
);
expect
(
view
.
modifyRole
).
toHaveBeenCalled
();
expect
(
sent_IQ
.
toLocaleString
()).
toBe
(
"
<iq to='lounge@localhost' type='set' xmlns='jabber:client' id='
"
+
IQ_id
+
"
'>
"
+
"
<query xmlns='http://jabber.org/protocol/muc#admin'>
"
+
"
<item nick='annoyingGuy' role='participant'>
"
+
"
<reason>Now you can talk again</reason>
"
+
"
</item>
"
+
"
</query>
"
+
"
</iq>
"
);
/* <presence
* from='coven@chat.shakespeare.lit/thirdwitch'
* to='crone1@shakespeare.lit/desktop'>
* <x xmlns='http://jabber.org/protocol/muc#user'>
* <item affiliation='member'
* jid='hag66@shakespeare.lit/pda'
* role='visitor'/>
* </x>
* </presence>
*/
presence
=
$pres
({
'
from
'
:
'
lounge@localhost/annoyingGuy
'
,
'
to
'
:
'
dummy@localhost/desktop
'
})
.
c
(
'
x
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/muc#user
'
})
.
c
(
'
item
'
,
{
'
jid
'
:
'
annoyingguy@localhost
'
,
'
affiliation
'
:
'
member
'
,
'
role
'
:
'
participant
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
info_msgs
=
Array
.
prototype
.
slice
.
call
(
view
.
el
.
querySelectorAll
(
'
.chat-info
'
),
0
);
expect
(
info_msgs
.
pop
().
textContent
).
toBe
(
"
annoyingGuy has been given a voice again.
"
);
done
();
});
}));
...
...
src/converse-muc.js
View file @
dc169304
...
...
@@ -510,10 +510,28 @@
return
this
;
},
informOfOccupantsRoleChange
(
occupant
)
{
informOfOccupantsRoleChange
(
occupant
,
changed
)
{
const
previous_role
=
occupant
.
_previousAttributes
.
role
;
if
(
previous_role
===
'
moderator
'
)
{
this
.
showStatusNotification
(
__
(
"
%1$s is no longer a moderator.
"
,
occupant
.
get
(
'
nick
'
)),
false
,
true
)
}
if
(
previous_role
===
'
visitor
'
)
{
this
.
showStatusNotification
(
__
(
"
%1$s has been given a voice again.
"
,
occupant
.
get
(
'
nick
'
)),
false
,
true
)
}
if
(
occupant
.
get
(
'
role
'
)
===
'
visitor
'
)
{
this
.
showStatusNotification
(
__
(
"
%1$s has been muted.
"
,
occupant
.
get
(
'
nick
'
)),
false
,
true
)
__
(
"
%1$s has been muted.
"
,
occupant
.
get
(
'
nick
'
)),
false
,
true
)
}
if
(
occupant
.
get
(
'
role
'
)
===
'
moderator
'
)
{
this
.
showStatusNotification
(
__
(
"
%1$s is now a moderator.
"
,
occupant
.
get
(
'
nick
'
)),
false
,
true
)
}
},
...
...
@@ -1023,7 +1041,7 @@
case
'
deop
'
:
if
(
!
this
.
validateRoleChangeCommand
(
command
,
args
))
{
break
;
}
this
.
modifyRole
(
this
.
model
.
get
(
'
jid
'
),
args
[
0
],
'
occu
pant
'
,
args
[
1
],
this
.
model
.
get
(
'
jid
'
),
args
[
0
],
'
partici
pant
'
,
args
[
1
],
undefined
,
this
.
onCommandError
.
bind
(
this
));
break
;
case
'
help
'
:
...
...
@@ -1031,7 +1049,7 @@
`<strong>/admin</strong>:
${
__
(
"
Change user's affiliation to admin
"
)}
`
,
`<strong>/ban</strong>:
${
__
(
'
Ban user from room
'
)}
`
,
`<strong>/clear</strong>:
${
__
(
'
Remove messages
'
)}
`
,
`<strong>/deop</strong>:
${
__
(
'
Change user role to
occu
pant
'
)}
`
,
`<strong>/deop</strong>:
${
__
(
'
Change user role to
partici
pant
'
)}
`
,
`<strong>/help</strong>:
${
__
(
'
Show this menu
'
)}
`
,
`<strong>/kick</strong>:
${
__
(
'
Kick user from room
'
)}
`
,
`<strong>/me</strong>:
${
__
(
'
Write in 3rd person
'
)}
`
,
...
...
@@ -1105,7 +1123,7 @@
case
'
voice
'
:
if
(
!
this
.
validateRoleChangeCommand
(
command
,
args
))
{
break
;
}
this
.
modifyRole
(
this
.
model
.
get
(
'
jid
'
),
args
[
0
],
'
occu
pant
'
,
args
[
1
],
this
.
model
.
get
(
'
jid
'
),
args
[
0
],
'
partici
pant
'
,
args
[
1
],
undefined
,
this
.
onCommandError
.
bind
(
this
));
break
;
default
:
...
...
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