2018-04-24 14:35:47 +02:00
|
|
|
// Converse.js
|
2017-02-02 19:29:38 +01:00
|
|
|
// http://conversejs.org
|
|
|
|
//
|
2018-04-24 14:35:47 +02:00
|
|
|
// Copyright (c) 2012-2018, the Converse.js developers
|
2017-02-02 19:29:38 +01:00
|
|
|
// Licensed under the Mozilla Public License (MPLv2)
|
2018-04-24 14:35:47 +02:00
|
|
|
|
2017-01-16 22:15:07 +01:00
|
|
|
(function (root, factory) {
|
2017-02-14 15:08:39 +01:00
|
|
|
define(["converse-core", "converse-muc"], factory);
|
2017-01-16 22:15:07 +01:00
|
|
|
}(this, function (converse) {
|
|
|
|
"use strict";
|
2017-07-10 17:46:22 +02:00
|
|
|
const { Backbone, _ } = converse.env;
|
2017-01-16 22:15:07 +01:00
|
|
|
|
|
|
|
converse.plugins.add('converse-muc-embedded', {
|
2018-02-09 16:33:48 +01:00
|
|
|
|
|
|
|
enabled (_converse) {
|
|
|
|
return _converse.view_mode === 'embedded';
|
|
|
|
},
|
|
|
|
|
2017-07-10 17:46:22 +02:00
|
|
|
initialize () {
|
2017-04-28 19:52:42 +02:00
|
|
|
/* The initialize function gets called as soon as the plugin is
|
|
|
|
* loaded by converse.js's plugin machinery.
|
|
|
|
*/
|
2018-02-09 16:33:48 +01:00
|
|
|
this._converse.api.settings.update({
|
|
|
|
'allow_logout': false, // No point in logging out when we have auto_login as true.
|
|
|
|
'allow_muc_invitations': false, // Doesn't make sense to allow because only
|
|
|
|
// roster contacts can be invited
|
|
|
|
'hide_muc_server': true, // Federation is disabled, so no use in
|
|
|
|
// showing the MUC server.
|
|
|
|
});
|
2017-07-10 17:46:22 +02:00
|
|
|
const { _converse } = this;
|
2017-04-28 19:52:42 +02:00
|
|
|
if (!_.isArray(_converse.auto_join_rooms)) {
|
|
|
|
throw new Error("converse-muc-embedded: auto_join_rooms must be an Array");
|
|
|
|
}
|
|
|
|
if (_converse.auto_join_rooms.length !== 1) {
|
|
|
|
throw new Error("converse-muc-embedded: It doesn't make "+
|
|
|
|
"sense to have the auto_join_rooms setting to zero or "+
|
|
|
|
"more then one, since only one chat room can be open "+
|
2017-06-12 20:30:58 +02:00
|
|
|
"at any time.");
|
2017-04-28 19:52:42 +02:00
|
|
|
}
|
|
|
|
}
|
2017-01-16 22:15:07 +01:00
|
|
|
});
|
|
|
|
}));
|