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
ebc7409d
Commit
ebc7409d
authored
Nov 20, 2016
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable new rooms to be configured automatically
Via `rooms.open` API method.
parent
ea71ca4b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
94 additions
and
12 deletions
+94
-12
docs/CHANGES.md
docs/CHANGES.md
+2
-0
docs/source/developer_api.rst
docs/source/developer_api.rst
+38
-3
src/converse-muc.js
src/converse-muc.js
+54
-9
No files found.
docs/CHANGES.md
View file @
ebc7409d
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
## 2.0.2 (Unreleased)
## 2.0.2 (Unreleased)
-
#721 keepalive not working with anonymous authentication [jcbrand]
-
#721 keepalive not working with anonymous authentication [jcbrand]
-
Enable new rooms to be configured automatically, with a default config, via
`rooms.open`
.
For details, refer to the
[
relevant documentation
](
https://conversejs.org/docs/html/developer_api.html#the-rooms-grouping
)
[
jcbrand
]
## 2.0.1 (2016-11-07)
## 2.0.1 (2016-11-07)
-
#203 New configuration setting
[
muc_domain
](
https://conversejs.org/docs/html/configuration.html#muc_domain
)
[
jcbrand
]
-
#203 New configuration setting
[
muc_domain
](
https://conversejs.org/docs/html/configuration.html#muc_domain
)
[
jcbrand
]
...
...
docs/source/developer_api.rst
View file @
ebc7409d
...
@@ -540,12 +540,12 @@ open
...
@@ -540,12 +540,12 @@ open
~~~~
~~~~
Opens a multi user chat box and returns an object representing it.
Opens a multi user chat box and returns an object representing it.
Similar to
chats.get API
Similar to
the ``chats.get`` API.
It takes 2 parameters:
It takes 2 parameters:
*
the room JID (if not specified, all
rooms will be returned).
*
The room JID or JIDs (if not specified, all currently open
rooms will be returned).
*
a
map (object) containing any extra room attributes. For example, if you want
*
A
map (object) containing any extra room attributes. For example, if you want
to specify the nickname, use ``{'nick': 'bloodninja'}``.
to specify the nickname, use ``{'nick': 'bloodninja'}``.
To open a single multi user chat box, provide the JID of the room:
To open a single multi user chat box, provide the JID of the room:
...
@@ -566,6 +566,41 @@ To setup a custom nickname when joining the room, provide the optional nick argu
...
@@ -566,6 +566,41 @@ To setup a custom nickname when joining the room, provide the optional nick argu
converse.rooms.open('group@muc.example.com', {'nick': 'mycustomnick'})
converse.rooms.open('group@muc.example.com', {'nick': 'mycustomnick'})
Room attributes that may be passed in:
* *nick*: The nickname to be used
* *auto_configure*: A boolean, indicating whether the room should be configured
automatically or not. If set to ``true``, then it makes sense to pass in
configuration settings.
* *roomconfig*: A map of configuration settings to be used when the room gets
configured automatically. Currently it doesn't make sense to specify
``roomconfig`` values if ``auto_configure`` is set to ``false``.
For a list of configuration values that can be passed in, refer to these values
in the `XEP-0045 MUC specification <http://xmpp.org/extensions/xep-0045.html#registrar-formtype-owner>`_.
The values should be named without the ``muc#roomconfig_`` prefix.
For example, opening a room with a specific default configuration:
.. code-block:: javascript
converse.rooms.open(
'myroom@conference.example.org',
{ 'nick': 'coolguy69',
'auto_configure': true,
'roomconfig': {
'changesubject': false,
'membersonly': true,
'persistentroom': true,
'publicroom': true,
'roomdesc': 'Comfy room for hanging out',
'whois': 'anyone'
}
},
true
);
.. note:: `multi-list` configuration values are not yet supported.
close
close
~~~~~
~~~~~
...
...
src/converse-muc.js
View file @
ebc7409d
...
@@ -754,6 +754,44 @@
...
@@ -754,6 +754,44 @@
});
});
},
},
autoConfigureChatRoom
:
function
(
stanza
)
{
/* Automatically configure room based on the
* 'roomconfigure' data on this view's model.
*/
var
that
=
this
,
configArray
=
[],
$fields
=
$
(
stanza
).
find
(
'
field
'
),
count
=
$fields
.
length
,
config
=
this
.
model
.
get
(
'
roomconfig
'
);
$fields
.
each
(
function
()
{
var
fieldname
=
this
.
getAttribute
(
'
var
'
).
replace
(
'
muc#roomconfig_
'
,
''
),
type
=
this
.
getAttribute
(
'
type
'
),
value
;
if
(
fieldname
in
config
)
{
switch
(
type
)
{
case
'
boolean
'
:
value
=
config
[
fieldname
]
?
1
:
0
;
break
;
case
'
list-multi
'
:
// TODO: we don't yet handle "list-multi" types
value
=
this
.
innerHTML
;
break
;
default
:
value
=
config
[
fieldname
];
}
this
.
innerHTML
=
$build
(
'
value
'
).
t
(
value
);
}
configArray
.
push
(
this
);
if
(
!--
count
)
{
that
.
sendConfiguration
(
configArray
,
that
.
onConfigSaved
.
bind
(
that
),
that
.
onErrorConfigSaved
.
bind
(
that
)
);
}
});
},
onConfigSaved
:
function
(
stanza
)
{
onConfigSaved
:
function
(
stanza
)
{
// TODO: provide feedback
// TODO: provide feedback
},
},
...
@@ -774,20 +812,27 @@
...
@@ -774,20 +812,27 @@
},
},
configureChatRoom
:
function
(
ev
)
{
configureChatRoom
:
function
(
ev
)
{
var
handleIQ
;
if
(
typeof
ev
!==
'
undefined
'
&&
ev
.
preventDefault
)
{
if
(
typeof
ev
!==
'
undefined
'
&&
ev
.
preventDefault
)
{
ev
.
preventDefault
();
ev
.
preventDefault
();
}
}
if
(
this
.
$el
.
find
(
'
div.chatroom-form-container
'
).
length
)
{
if
(
this
.
model
.
get
(
'
auto_configure
'
))
{
return
;
handleIQ
=
this
.
autoConfigureChatRoom
.
bind
(
this
);
}
else
{
if
(
this
.
$el
.
find
(
'
div.chatroom-form-container
'
).
length
)
{
return
;
}
var
$body
=
this
.
$
(
'
.chatroom-body
'
);
$body
.
children
().
addClass
(
'
hidden
'
);
$body
.
append
(
converse
.
templates
.
chatroom_form
());
handleIQ
=
this
.
renderConfigurationForm
.
bind
(
this
);
}
}
this
.
$
(
'
.chatroom-body
'
).
children
().
addClass
(
'
hidden
'
);
this
.
$
(
'
.chatroom-body
'
).
append
(
converse
.
templates
.
chatroom_form
());
converse
.
connection
.
sendIQ
(
converse
.
connection
.
sendIQ
(
$iq
({
$iq
({
to
:
this
.
model
.
get
(
'
jid
'
),
'
to
'
:
this
.
model
.
get
(
'
jid
'
),
type
:
"
get
"
'
type
'
:
"
get
"
}).
c
(
"
query
"
,
{
xmlns
:
Strophe
.
NS
.
MUC_OWNER
}).
tree
(),
}).
c
(
"
query
"
,
{
xmlns
:
Strophe
.
NS
.
MUC_OWNER
}).
tree
(),
this
.
renderConfigurationForm
.
bind
(
this
)
handleIQ
);
);
},
},
...
...
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