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
54371f0e
Commit
54371f0e
authored
Dec 07, 2016
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove `setAffiliation` and use the more general purpose `setAffiliations`
parent
77d3e64f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
38 deletions
+33
-38
spec/chatroom.js
spec/chatroom.js
+3
-3
src/converse-muc.js
src/converse-muc.js
+30
-35
No files found.
spec/chatroom.js
View file @
54371f0e
...
@@ -1167,7 +1167,7 @@
...
@@ -1167,7 +1167,7 @@
test_utils
.
openChatRoom
(
converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
test_utils
.
openChatRoom
(
converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
var
view
=
converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
var
view
=
converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
spyOn
(
view
,
'
onMessageSubmitted
'
).
andCallThrough
();
spyOn
(
view
,
'
onMessageSubmitted
'
).
andCallThrough
();
spyOn
(
view
,
'
setAffiliation
'
).
andCallThrough
();
spyOn
(
view
,
'
setAffiliation
s
'
).
andCallThrough
();
spyOn
(
view
,
'
showStatusNotification
'
).
andCallThrough
();
spyOn
(
view
,
'
showStatusNotification
'
).
andCallThrough
();
spyOn
(
view
,
'
validateRoleChangeCommand
'
).
andCallThrough
();
spyOn
(
view
,
'
validateRoleChangeCommand
'
).
andCallThrough
();
view
.
$el
.
find
(
'
.chat-textarea
'
).
text
(
'
/ban
'
);
view
.
$el
.
find
(
'
.chat-textarea
'
).
text
(
'
/ban
'
);
...
@@ -1178,7 +1178,7 @@
...
@@ -1178,7 +1178,7 @@
"
Error: the
\"
ban
\"
command takes two arguments, the user's nickname and optionally a reason.
"
,
"
Error: the
\"
ban
\"
command takes two arguments, the user's nickname and optionally a reason.
"
,
true
true
);
);
expect
(
view
.
setAffiliation
).
not
.
toHaveBeenCalled
();
expect
(
view
.
setAffiliation
s
).
not
.
toHaveBeenCalled
();
// Call now with the correct amount of arguments.
// Call now with the correct amount of arguments.
// XXX: Calling onMessageSubmitted directly, trying
// XXX: Calling onMessageSubmitted directly, trying
...
@@ -1187,7 +1187,7 @@
...
@@ -1187,7 +1187,7 @@
view
.
onMessageSubmitted
(
'
/ban jid This is the reason
'
);
view
.
onMessageSubmitted
(
'
/ban jid This is the reason
'
);
expect
(
view
.
validateRoleChangeCommand
.
callCount
).
toBe
(
2
);
expect
(
view
.
validateRoleChangeCommand
.
callCount
).
toBe
(
2
);
expect
(
view
.
showStatusNotification
.
callCount
).
toBe
(
1
);
expect
(
view
.
showStatusNotification
.
callCount
).
toBe
(
1
);
expect
(
view
.
setAffiliation
).
toHaveBeenCalled
();
expect
(
view
.
setAffiliation
s
).
toHaveBeenCalled
();
}));
}));
});
});
...
...
src/converse-muc.js
View file @
54371f0e
...
@@ -780,13 +780,6 @@
...
@@ -780,13 +780,6 @@
});
});
},
},
setAffiliation
:
function
(
room
,
jid
,
affiliation
,
reason
,
onSuccess
,
onError
)
{
var
item
=
$build
(
"
item
"
,
{
jid
:
jid
,
affiliation
:
affiliation
});
var
iq
=
$iq
({
to
:
room
,
type
:
"
set
"
}).
c
(
"
query
"
,
{
xmlns
:
Strophe
.
NS
.
MUC_ADMIN
}).
cnode
(
item
.
node
);
if
(
reason
!==
null
)
{
iq
.
c
(
"
reason
"
,
reason
);
}
return
converse
.
connection
.
sendIQ
(
iq
.
tree
(),
onSuccess
,
onError
);
},
modifyRole
:
function
(
room
,
nick
,
role
,
reason
,
onSuccess
,
onError
)
{
modifyRole
:
function
(
room
,
nick
,
role
,
reason
,
onSuccess
,
onError
)
{
var
item
=
$build
(
"
item
"
,
{
nick
:
nick
,
role
:
role
});
var
item
=
$build
(
"
item
"
,
{
nick
:
nick
,
role
:
role
});
var
iq
=
$iq
({
to
:
room
,
type
:
"
set
"
}).
c
(
"
query
"
,
{
xmlns
:
Strophe
.
NS
.
MUC_ADMIN
}).
cnode
(
item
.
node
);
var
iq
=
$iq
({
to
:
room
,
type
:
"
set
"
}).
c
(
"
query
"
,
{
xmlns
:
Strophe
.
NS
.
MUC_ADMIN
}).
cnode
(
item
.
node
);
...
@@ -794,19 +787,6 @@
...
@@ -794,19 +787,6 @@
return
converse
.
connection
.
sendIQ
(
iq
.
tree
(),
onSuccess
,
onError
);
return
converse
.
connection
.
sendIQ
(
iq
.
tree
(),
onSuccess
,
onError
);
},
},
member
:
function
(
room
,
jid
,
reason
,
handler_cb
,
error_cb
)
{
return
this
.
setAffiliation
(
room
,
jid
,
'
member
'
,
reason
,
handler_cb
,
error_cb
);
},
revoke
:
function
(
room
,
jid
,
reason
,
handler_cb
,
error_cb
)
{
return
this
.
setAffiliation
(
room
,
jid
,
'
none
'
,
reason
,
handler_cb
,
error_cb
);
},
owner
:
function
(
room
,
jid
,
reason
,
handler_cb
,
error_cb
)
{
return
this
.
setAffiliation
(
room
,
jid
,
'
owner
'
,
reason
,
handler_cb
,
error_cb
);
},
admin
:
function
(
room
,
jid
,
reason
,
handler_cb
,
error_cb
)
{
return
this
.
setAffiliation
(
room
,
jid
,
'
admin
'
,
reason
,
handler_cb
,
error_cb
);
},
validateRoleChangeCommand
:
function
(
command
,
args
)
{
validateRoleChangeCommand
:
function
(
command
,
args
)
{
/* Check that a command to change a chat room user's role or
/* Check that a command to change a chat room user's role or
* affiliation has anough arguments.
* affiliation has anough arguments.
...
@@ -849,15 +829,21 @@
...
@@ -849,15 +829,21 @@
switch
(
match
[
1
])
{
switch
(
match
[
1
])
{
case
'
admin
'
:
case
'
admin
'
:
if
(
!
this
.
validateRoleChangeCommand
(
match
[
1
],
args
))
{
break
;
}
if
(
!
this
.
validateRoleChangeCommand
(
match
[
1
],
args
))
{
break
;
}
this
.
setAffiliation
(
this
.
setAffiliations
(
this
.
model
.
get
(
'
jid
'
),
args
[
0
],
'
admin
'
,
args
[
1
],
[{
'
jid
'
:
args
[
0
],
undefined
,
this
.
onCommandError
.
bind
(
this
));
'
affiliation
'
:
'
admin
'
,
'
reason
'
:
args
[
1
]
}],
undefined
,
this
.
onCommandError
.
bind
(
this
)
);
break
;
break
;
case
'
ban
'
:
case
'
ban
'
:
if
(
!
this
.
validateRoleChangeCommand
(
match
[
1
],
args
))
{
break
;
}
if
(
!
this
.
validateRoleChangeCommand
(
match
[
1
],
args
))
{
break
;
}
this
.
setAffiliation
(
this
.
setAffiliations
(
this
.
model
.
get
(
'
jid
'
),
args
[
0
],
'
outcast
'
,
args
[
1
],
[{
'
jid
'
:
args
[
0
],
undefined
,
this
.
onCommandError
.
bind
(
this
));
'
affiliation
'
:
'
outcast
'
,
'
reason
'
:
args
[
1
]
}],
undefined
,
this
.
onCommandError
.
bind
(
this
)
);
break
;
break
;
case
'
clear
'
:
case
'
clear
'
:
this
.
clearChatRoomMessages
();
this
.
clearChatRoomMessages
();
...
@@ -901,9 +887,12 @@
...
@@ -901,9 +887,12 @@
break
;
break
;
case
'
member
'
:
case
'
member
'
:
if
(
!
this
.
validateRoleChangeCommand
(
match
[
1
],
args
))
{
break
;
}
if
(
!
this
.
validateRoleChangeCommand
(
match
[
1
],
args
))
{
break
;
}
this
.
setAffiliation
(
this
.
setAffiliations
(
this
.
model
.
get
(
'
jid
'
),
args
[
0
],
'
member
'
,
args
[
1
],
[{
'
jid
'
:
args
[
0
],
undefined
,
this
.
onCommandError
.
bind
(
this
));
'
affiliation
'
:
'
member
'
,
'
reason
'
:
args
[
1
]
}],
undefined
,
this
.
onCommandError
.
bind
(
this
)
);
break
;
break
;
case
'
nick
'
:
case
'
nick
'
:
converse
.
connection
.
send
(
$pres
({
converse
.
connection
.
send
(
$pres
({
...
@@ -914,9 +903,12 @@
...
@@ -914,9 +903,12 @@
break
;
break
;
case
'
owner
'
:
case
'
owner
'
:
if
(
!
this
.
validateRoleChangeCommand
(
match
[
1
],
args
))
{
break
;
}
if
(
!
this
.
validateRoleChangeCommand
(
match
[
1
],
args
))
{
break
;
}
this
.
setAffiliation
(
this
.
setAffiliations
(
this
.
model
.
get
(
'
jid
'
),
args
[
0
],
'
owner
'
,
args
[
1
],
[{
'
jid
'
:
args
[
0
],
undefined
,
this
.
onCommandError
.
bind
(
this
));
'
affiliation
'
:
'
owner
'
,
'
reason
'
:
args
[
1
]
}],
undefined
,
this
.
onCommandError
.
bind
(
this
)
);
break
;
break
;
case
'
op
'
:
case
'
op
'
:
if
(
!
this
.
validateRoleChangeCommand
(
match
[
1
],
args
))
{
break
;
}
if
(
!
this
.
validateRoleChangeCommand
(
match
[
1
],
args
))
{
break
;
}
...
@@ -926,9 +918,12 @@
...
@@ -926,9 +918,12 @@
break
;
break
;
case
'
revoke
'
:
case
'
revoke
'
:
if
(
!
this
.
validateRoleChangeCommand
(
match
[
1
],
args
))
{
break
;
}
if
(
!
this
.
validateRoleChangeCommand
(
match
[
1
],
args
))
{
break
;
}
this
.
setAffiliation
(
this
.
setAffiliations
(
this
.
model
.
get
(
'
jid
'
),
args
[
0
],
'
none
'
,
args
[
1
],
[{
'
jid
'
:
args
[
0
],
undefined
,
this
.
onCommandError
.
bind
(
this
));
'
affiliation
'
:
'
none
'
,
'
reason
'
:
args
[
1
]
}],
undefined
,
this
.
onCommandError
.
bind
(
this
)
);
break
;
break
;
case
'
topic
'
:
case
'
topic
'
:
converse
.
connection
.
send
(
converse
.
connection
.
send
(
...
...
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