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

updates #203
This commit is contained in:
JC Brand 2016-10-26 13:21:36 +00:00
parent 04aee5d533
commit aad90cc9df
3 changed files with 38 additions and 17 deletions

View File

@ -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]

View File

@ -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
-----------------------

View File

@ -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