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
4f67f352
Commit
4f67f352
authored
Jun 18, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix `/${command}` parsing bug
parent
6a419cc1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
7 deletions
+36
-7
spec/muc.js
spec/muc.js
+23
-3
src/converse-muc-views.js
src/converse-muc-views.js
+13
-4
No files found.
spec/muc.js
View file @
4f67f352
...
...
@@ -3180,8 +3180,10 @@
keyCode
:
13
});
expect
(
view
.
validateRoleOrAffiliationChangeArgs
).
toHaveBeenCalled
();
expect
(
view
.
showErrorMessage
).
toHaveBeenCalledWith
(
expect
(
view
.
showErrorMessage
).
toHaveBeenCalled
();
expect
(
view
.
el
.
querySelector
(
'
.message:first-child
'
).
textContent
).
toBe
(
"
Error: the
\"
ban
\"
command takes two arguments, the user's nickname and optionally a reason.
"
);
expect
(
view
.
model
.
setAffiliation
).
not
.
toHaveBeenCalled
();
// Call now with the correct amount of arguments.
// XXX: Calling onFormSubmitted directly, trying
...
...
@@ -3215,12 +3217,30 @@
'
role
'
:
'
participant
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-info
'
)[
3
].
textContent
).
toBe
(
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-info
'
)[
3
].
textContent
).
toBe
(
"
annoyingGuy has been banned from this groupchat
"
);
presence
=
$pres
({
'
from
'
:
'
lounge@montague.lit/joe2
'
,
'
id
'
:
'
27C55F89-1C6A-459A-9EB5-77690145D624
'
,
'
to
'
:
'
romeo@montague.lit/desktop
'
})
.
c
(
'
x
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/muc#user
'
})
.
c
(
'
item
'
,
{
'
jid
'
:
'
joe2@montague.lit
'
,
'
affiliation
'
:
'
member
'
,
'
role
'
:
'
participant
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
textarea
.
value
=
'
/ban joe22
'
;
view
.
onFormSubmitted
(
new
Event
(
'
submit
'
));
expect
(
view
.
el
.
querySelector
(
'
.message:first-child
'
).
textContent
).
toBe
(
"
Error: couldn't find a groupchat participant based on your arguments
"
);
done
();
}));
it
(
"
takes a /kick command to kick a user
"
,
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
...
...
src/converse-muc-views.js
View file @
4f67f352
...
...
@@ -854,9 +854,18 @@ converse.plugins.add('converse-muc-views', {
const
[
text
,
references
]
=
this
.
model
.
parseTextForReferences
(
args
);
if
(
!
references
.
length
)
{
this
.
showErrorMessage
(
__
(
"
Error: couldn't find a groupchat participant based on your arguments
"
));
return
false
;
return
;
}
if
(
references
.
length
>
1
)
{
this
.
showErrorMessage
(
__
(
"
Error: found multiple groupchat participant based on your arguments
"
));
return
;
}
const
nick_or_jid
=
references
.
pop
().
value
;
if
(
!
args
.
split
(
nick_or_jid
,
2
)[
1
].
startsWith
(
'
'
))
{
this
.
showErrorMessage
(
__
(
"
Error: couldn't find a groupchat participant based on your arguments
"
));
return
;
}
return
references
.
pop
()
;
return
nick_or_jid
;
},
setAffiliation
(
command
,
args
,
required_affiliations
)
{
...
...
@@ -870,7 +879,7 @@ converse.plugins.add('converse-muc-views', {
if
(
!
this
.
validateRoleOrAffiliationChangeArgs
(
command
,
args
))
{
return
false
;
}
const
nick_or_jid
=
_
.
get
(
this
.
getNickOrJIDFromCommandArgs
(
args
),
'
value
'
,
null
);
const
nick_or_jid
=
this
.
getNickOrJIDFromCommandArgs
(
args
);
if
(
!
nick_or_jid
)
{
return
false
;
}
...
...
@@ -907,7 +916,7 @@ converse.plugins.add('converse-muc-views', {
if
(
!
this
.
validateRoleOrAffiliationChangeArgs
(
command
,
args
))
{
return
false
;
}
const
nick_or_jid
=
_
.
get
(
this
.
getNickOrJIDFromCommandArgs
(
args
),
'
value
'
,
null
);
const
nick_or_jid
=
this
.
getNickOrJIDFromCommandArgs
(
args
);
if
(
!
nick_or_jid
)
{
return
false
;
}
...
...
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