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
c893a51a
Commit
c893a51a
authored
Mar 01, 2015
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rewrite the MUC commands to not use strophe.muc. updates #307
Also added 3 new commands, /member, /revoke, /admin
parent
acd3463a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
87 additions
and
17 deletions
+87
-17
converse.js
converse.js
+87
-17
No files found.
converse.js
View file @
c893a51a
...
...
@@ -2434,54 +2434,124 @@
});
},
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
)
{
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
);
if
(
reason
!==
null
)
{
iq
.
c
(
"
reason
"
,
reason
);
}
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
);
},
sendChatRoomMessage
:
function
(
text
)
{
var
match
=
text
.
replace
(
/^
\s
*/
,
""
).
match
(
/^
\/(
.*
?)(?:
(
.*
))?
$/
)
||
[
false
],
args
;
var
match
=
text
.
replace
(
/^
\s
*/
,
""
).
match
(
/^
\/(
.*
?)(?:
(
.*
))?
$/
)
||
[
false
,
''
,
''
];
var
args
=
match
[
2
].
splitOnce
(
'
'
);
switch
(
match
[
1
])
{
case
'
admin
'
:
this
.
setAffiliation
(
this
.
model
.
get
(
'
jid
'
),
args
[
0
],
'
admin
'
,
args
[
1
],
undefined
,
$
.
proxy
(
this
.
onCommandError
,
this
));
break
;
case
'
ban
'
:
args
=
match
[
2
].
splitOnce
(
'
'
);
converse
.
connection
.
muc
.
ban
(
this
.
model
.
get
(
'
jid
'
),
args
[
0
],
args
[
1
],
undefined
,
$
.
proxy
(
this
.
onCommandError
,
this
));
this
.
setAffiliation
(
this
.
model
.
get
(
'
jid
'
),
args
[
0
],
'
outcast
'
,
args
[
1
],
undefined
,
$
.
proxy
(
this
.
onCommandError
,
this
));
break
;
case
'
clear
'
:
this
.
clearChatRoomMessages
();
break
;
case
'
deop
'
:
args
=
match
[
2
].
splitOnce
(
'
'
);
converse
.
connection
.
muc
.
deop
(
this
.
model
.
get
(
'
jid
'
),
args
[
0
],
args
[
1
],
undefined
,
$
.
proxy
(
this
.
onCommandError
,
this
));
this
.
modifyRole
(
this
.
model
.
get
(
'
jid
'
),
args
[
0
],
'
participant
'
,
args
[
1
],
undefined
,
$
.
proxy
(
this
.
onCommandError
,
this
));
break
;
case
'
help
'
:
this
.
showHelpMessages
([
'
<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 participant
'
),
'
<strong>/help</strong>:
'
+
__
(
'
Show this menu
'
),
'
<strong>/kick</strong>:
'
+
__
(
'
Kick user from room
'
),
'
<strong>/me</strong>:
'
+
__
(
'
Write in 3rd person
'
),
'
<strong>/member</strong>:
'
+
__
(
'
Grant membership to a user
'
),
'
<strong>/mute</strong>:
'
+
__
(
"
Remove user's ability to post messages
"
),
'
<strong>/nick</strong>:
'
+
__
(
'
Change your nickname
'
),
'
<strong>/op</strong>:
'
+
__
(
'
Grant moderator role to user
'
),
'
<strong>/owner</strong>:
'
+
__
(
'
Grant ownership of this room
'
),
'
<strong>/revoke</strong>:
'
+
__
(
"
Revoke user's membership
"
),
'
<strong>/topic</strong>:
'
+
__
(
'
Set room topic
'
),
'
<strong>/voice</strong>:
'
+
__
(
'
Allow muted user to post messages
'
)
]);
break
;
case
'
kick
'
:
args
=
match
[
2
].
splitOnce
(
'
'
);
converse
.
connection
.
muc
.
kick
(
this
.
model
.
get
(
'
jid
'
),
args
[
0
],
args
[
1
],
undefined
,
$
.
proxy
(
this
.
onCommandError
,
this
));
this
.
modifyRole
(
this
.
model
.
get
(
'
jid
'
),
args
[
0
],
'
none
'
,
args
[
1
],
undefined
,
$
.
proxy
(
this
.
onCommandError
,
this
));
break
;
case
'
mute
'
:
args
=
match
[
2
].
splitOnce
(
'
'
);
converse
.
connection
.
muc
.
mute
(
this
.
model
.
get
(
'
jid
'
),
args
[
0
],
args
[
1
],
undefined
,
$
.
proxy
(
this
.
onCommandError
,
this
));
this
.
modifyRole
(
this
.
model
.
get
(
'
jid
'
),
args
[
0
],
'
visitor
'
,
args
[
1
],
undefined
,
$
.
proxy
(
this
.
onCommandError
,
this
));
break
;
case
'
member
'
:
this
.
setAffiliation
(
this
.
model
.
get
(
'
jid
'
),
args
[
0
],
'
member
'
,
args
[
1
],
undefined
,
$
.
proxy
(
this
.
onCommandError
,
this
));
break
;
case
'
nick
'
:
converse
.
connection
.
muc
.
changeNick
(
this
.
model
.
get
(
'
jid
'
),
match
[
2
]);
converse
.
connection
.
send
(
$pres
({
from
:
converse
.
connection
.
jid
,
to
:
this
.
getRoomJID
(
match
[
2
]),
id
:
converse
.
connection
.
getUniqueId
()
}).
tree
());
break
;
case
'
owner
'
:
this
.
setAffiliation
(
this
.
model
.
get
(
'
jid
'
),
args
[
0
],
'
owner
'
,
args
[
1
],
undefined
,
$
.
proxy
(
this
.
onCommandError
,
this
));
break
;
case
'
op
'
:
args
=
match
[
2
].
splitOnce
(
'
'
);
converse
.
connection
.
muc
.
op
(
this
.
model
.
get
(
'
jid
'
),
args
[
0
],
args
[
1
],
undefined
,
$
.
proxy
(
this
.
onCommandError
,
this
));
this
.
modifyRole
(
this
.
model
.
get
(
'
jid
'
),
args
[
0
],
'
moderator
'
,
args
[
1
],
undefined
,
$
.
proxy
(
this
.
onCommandError
,
this
));
break
;
case
'
revoke
'
:
this
.
setAffiliation
(
this
.
model
.
get
(
'
jid
'
),
args
[
0
],
'
none
'
,
args
[
1
],
undefined
,
$
.
proxy
(
this
.
onCommandError
,
this
));
break
;
case
'
topic
'
:
converse
.
connection
.
muc
.
setTopic
(
this
.
model
.
get
(
'
jid
'
),
match
[
2
]);
converse
.
connection
.
send
(
$msg
({
to
:
this
.
model
.
get
(
'
jid
'
),
from
:
converse
.
connection
.
jid
,
type
:
"
groupchat
"
}).
c
(
"
subject
"
,
{
xmlns
:
"
jabber:client
"
}).
t
(
match
[
2
]).
tree
()
);
break
;
case
'
voice
'
:
args
=
match
[
2
].
splitOnce
(
'
'
);
converse
.
connection
.
muc
.
voice
(
this
.
model
.
get
(
'
jid
'
),
args
[
0
],
args
[
1
],
undefined
,
$
.
proxy
(
this
.
onCommandError
,
this
));
this
.
modifyRole
(
this
.
model
.
get
(
'
jid
'
),
args
[
0
],
'
participant
'
,
args
[
1
],
undefined
,
$
.
proxy
(
this
.
onCommandError
,
this
));
break
;
default
:
this
.
createChatRoomMessage
(
text
);
...
...
@@ -2512,9 +2582,9 @@
return
true
;
},
getRoomJID
:
function
()
{
getRoomJID
:
function
(
nick
)
{
nick
=
nick
||
this
.
model
.
get
(
'
nick
'
);
var
room
=
this
.
model
.
get
(
'
jid
'
);
var
nick
=
this
.
model
.
get
(
'
nick
'
);
var
node
=
Strophe
.
escapeNode
(
Strophe
.
getNodeFromJid
(
room
));
var
domain
=
Strophe
.
getDomainFromJid
(
room
);
return
node
+
"
@
"
+
domain
+
(
nick
!==
null
?
"
/
"
+
nick
:
""
);
...
...
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