Commit aad90cc9 authored by JC Brand's avatar JC Brand

Add the ability to set the MUC domain to be used.

updates #203
parent 04aee5d5
......@@ -9,6 +9,7 @@
- Start improving Content-Security-Policy compatibility by removing inline CSS. [mathiasertl]
- Add support for XEP-0048, chat room bookmarks [jcbrand]
- New configuration setting [connection_options](https://conversejs.org/docs/html/configuration.html#connection_options) [jcbrand]
- #203 New configuration setting [muc_domain](https://conversejs.org/docs/html/configuration.html#muc_domain) [jcbrand]
## 2.0.0 (2016-09-16)
- #656 Online users count not shown initially [amanzur]
......
......@@ -515,6 +515,8 @@ fullname
If you are using prebinding, can specify the fullname of the currently
logged in user, otherwise the user's vCard will be fetched.
.. _`hide_muc_server`:
hide_muc_server
---------------
......@@ -694,6 +696,17 @@ See also the `storage`_ option, which applies to other cached data, such as
which chats you have open, what features the XMPP server supports and what
your online status is.
muc_domain
----------
* Default: ``undefined``
The MUC (multi-user chat) domain that should be used. By default converse.js
will attempt to get the MUC domain from the XMPP host of the currently logged in
user.
This setting will override that. You might want to combine this setting with `hide_muc_server`_.
muc_history_max_stanzas
-----------------------
......
......@@ -146,33 +146,39 @@
},
onConnected: function () {
// TODO: This can probably be refactored to be an event
// handler (and therefore removed from overrides)
var converse = this.__super__.converse;
this.__super__.onConnected.apply(this, arguments);
if (this.model.get('connected')) {
converse.features.off('add', this.featureAdded, this);
converse.features.on('add', this.featureAdded, this);
// Features could have been added before the controlbox was
// initialized. We're only interested in MUC
var feature = converse.features.findWhere({
'var': Strophe.NS.MUC
});
if (feature) {
this.featureAdded(feature);
if (_.isUndefined(converse.muc_domain)) {
if (this.model.get('connected')) {
converse.features.off('add', this.featureAdded, this);
converse.features.on('add', this.featureAdded, this);
// Features could have been added before the controlbox was
// initialized. We're only interested in MUC
var feature = converse.features.findWhere({
'var': Strophe.NS.MUC
});
if (feature) {
this.featureAdded(feature);
}
}
} else {
this.setMUCDomain(converse.muc_domain);
}
},
setMUCDomain: function (domain) {
this.roomspanel.model.save({'muc_domain': domain});
var $server= this.$el.find('input.new-chatroom-server');
if (!$server.is(':focus')) {
$server.val(this.roomspanel.model.get('muc_domain'));
}
},
featureAdded: function (feature) {
var converse = this.__super__.converse;
if ((feature.get('var') === Strophe.NS.MUC) && (converse.allow_muc)) {
this.roomspanel.model.save({muc_domain: feature.get('from')});
var $server= this.$el.find('input.new-chatroom-server');
if (! $server.is(':focus')) {
$server.val(this.roomspanel.model.get('muc_domain'));
}
this.setMUCDomain(feature.get('from'));
}
}
},
......@@ -206,6 +212,7 @@
auto_join_rooms: [],
auto_list_rooms: false,
hide_muc_server: false,
muc_domain: undefined,
muc_history_max_stanzas: undefined,
muc_instant_rooms: true,
muc_nickname_from_jid: false
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment