summaryrefslogtreecommitdiff
path: root/addons/website_jitsi
diff options
context:
space:
mode:
authorstd-odoo <std@odoo.com>2020-08-11 11:37:50 +0000
committerstd-odoo <std@odoo.com>2020-08-13 12:19:17 +0000
commit50abd90b38a97d3c401e7849004694aa87bcb3cc (patch)
tree14d61f9890a1c79c40e72af8beb6c26e3dcefac4 /addons/website_jitsi
parent2923c8a6cfeb9a7afdead16144946791b97b665a (diff)
[IMP] website_jitsi: allow custom server deployment
Purpose ======= Allow to customize the domain name of the Jitsi server used to create chat room on website. This is done with an `ir.config_parameter`. Task-2316718 closes odoo/odoo#55869 Related: odoo/upgrade#1618 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Diffstat (limited to 'addons/website_jitsi')
-rw-r--r--addons/website_jitsi/__manifest__.py1
-rw-r--r--addons/website_jitsi/models/__init__.py1
-rw-r--r--addons/website_jitsi/models/chat_room.py10
-rw-r--r--addons/website_jitsi/models/res_config_settings.py12
-rw-r--r--addons/website_jitsi/static/src/js/chat_room.js22
-rw-r--r--addons/website_jitsi/views/chat_room_templates.xml3
-rw-r--r--addons/website_jitsi/views/res_config_settings.xml18
7 files changed, 62 insertions, 5 deletions
diff --git a/addons/website_jitsi/__manifest__.py b/addons/website_jitsi/__manifest__.py
index af6638c3739..d62dbc30406 100644
--- a/addons/website_jitsi/__manifest__.py
+++ b/addons/website_jitsi/__manifest__.py
@@ -16,6 +16,7 @@
'views/assets.xml',
'views/chat_room_templates.xml',
'views/chat_room_views.xml',
+ 'views/res_config_settings.xml',
],
'application': False,
}
diff --git a/addons/website_jitsi/models/__init__.py b/addons/website_jitsi/models/__init__.py
index 222bc1df76a..a58573d901b 100644
--- a/addons/website_jitsi/models/__init__.py
+++ b/addons/website_jitsi/models/__init__.py
@@ -3,3 +3,4 @@
from . import chat_room
from . import chat_room_mixin
+from . import res_config_settings
diff --git a/addons/website_jitsi/models/chat_room.py b/addons/website_jitsi/models/chat_room.py
index 8494f01c01d..401ba0d0242 100644
--- a/addons/website_jitsi/models/chat_room.py
+++ b/addons/website_jitsi/models/chat_room.py
@@ -29,6 +29,9 @@ class ChatRoom(models.Model):
"Room Name", required=True, copy=False,
default=lambda self: self._default_name())
is_full = fields.Boolean("Full", compute="_compute_is_full")
+ jitsi_server_domain = fields.Char(
+ 'Jitsi Server Domain', compute='_compute_jitsi_server_domain',
+ help='The Jitsi server domain can be customized through the settings to use a different server than the default "meet.jit.si"')
lang_id = fields.Many2one(
"res.lang", "Language",
default=lambda self: self.env["res.lang"].search([("code", "=", self.env.user.lang)], limit=1))
@@ -53,5 +56,12 @@ class ChatRoom(models.Model):
else:
room.is_full = room.participant_count >= int(room.max_capacity)
+ def _compute_jitsi_server_domain(self):
+ jitsi_server_domain = self.env['ir.config_parameter'].sudo().get_param(
+ 'website_jitsi.jitsi_server_domain', 'meet.jit.si')
+
+ for room in self:
+ room.jitsi_server_domain = jitsi_server_domain
+
def _jitsi_sanitize_name(self, name):
return re.sub(r'[^\w+.]+', '-', remove_accents(name).lower())
diff --git a/addons/website_jitsi/models/res_config_settings.py b/addons/website_jitsi/models/res_config_settings.py
new file mode 100644
index 00000000000..28308cadfd0
--- /dev/null
+++ b/addons/website_jitsi/models/res_config_settings.py
@@ -0,0 +1,12 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import fields, models
+
+
+class ResConfigSettings(models.TransientModel):
+ _inherit = 'res.config.settings'
+
+ jitsi_server_domain = fields.Char(
+ 'Jitsi Server Domain', default='meet.jit.si', config_parameter='website_jitsi.jitsi_server_domain',
+ help='The Jitsi server domain can be customized through the settings to use a different server than the default "meet.jit.si"')
diff --git a/addons/website_jitsi/static/src/js/chat_room.js b/addons/website_jitsi/static/src/js/chat_room.js
index f57a67a0a54..df29af0329e 100644
--- a/addons/website_jitsi/static/src/js/chat_room.js
+++ b/addons/website_jitsi/static/src/js/chat_room.js
@@ -15,6 +15,19 @@ publicWidget.registry.ChatRoom = publicWidget.Widget.extend({
'click .o_wjitsi_room_link': '_onChatRoomClick',
},
+ /**
+ * Manage the chat room (Jitsi), update the participant count...
+ *
+ * The widget takes some options
+ * - 'room-name', the name of the Jitsi room
+ * - 'chat-room-id', the ID of the `chat.room` record
+ * - 'auto-open', the chat room will be automatically opened when the page is loaded
+ * - 'check-full', check if the chat room is full before joining
+ * - 'attach-to', a JQuery selector of the element on which we will add the Jitsi
+ * iframe. If nothing is specified, it will open a modal instead.
+ * - 'default-username': the username to use in the chat room
+ * - 'jitsi-server': the domain name of the Jitsi server to use
+ */
start: async function () {
await this._super.apply(this, arguments);
this.roomName = this.$el.data('room-name');
@@ -29,6 +42,8 @@ publicWidget.registry.ChatRoom = publicWidget.Widget.extend({
// default username for jitsi
this.defaultUsername = this.$el.data('default-username') || false;
+ this.jitsiServer = this.$el.data('jitsi-server') || 'meet.jit.si';
+
if (this.autoOpen) {
await this._onChatRoomClick();
}
@@ -224,7 +239,7 @@ publicWidget.registry.ChatRoom = publicWidget.Widget.extend({
_openMobileApplication: async function (roomName) {
if (config.device.isMobile) {
// we are on mobile, open the room in the application
- window.location = `intent://meet.jit.si/${roomName}#Intent;scheme=org.jitsi.meet;package=org.jitsi.meet;end`;
+ window.location = `intent://${this.jitsiServer}/${roomName}#Intent;scheme=org.jitsi.meet;package=org.jitsi.meet;end`;
return true;
}
return false;
@@ -240,7 +255,6 @@ publicWidget.registry.ChatRoom = publicWidget.Widget.extend({
*/
_createJitsiRoom: async function (roomName, $parentNode) {
await this._loadJisti();
- const domain = "meet.jit.si";
const options = {
roomName: roomName,
width: "100%",
@@ -248,7 +262,7 @@ publicWidget.registry.ChatRoom = publicWidget.Widget.extend({
parentNode: $parentNode[0],
configOverwrite: {disableDeepLinking: true},
};
- return new window.JitsiMeetExternalAPI(domain, options);
+ return new window.JitsiMeetExternalAPI(this.jitsiServer, options);
},
/**
@@ -259,7 +273,7 @@ publicWidget.registry.ChatRoom = publicWidget.Widget.extend({
_loadJisti: async function () {
if (!window.JitsiMeetExternalAPI) {
await $.ajax({
- url: "https://meet.jit.si/external_api.js",
+ url: `https://${this.jitsiServer}/external_api.js`,
dataType: "script",
});
}
diff --git a/addons/website_jitsi/views/chat_room_templates.xml b/addons/website_jitsi/views/chat_room_templates.xml
index 69274f284ff..6d9386cf6bb 100644
--- a/addons/website_jitsi/views/chat_room_templates.xml
+++ b/addons/website_jitsi/views/chat_room_templates.xml
@@ -8,7 +8,8 @@
t-att-data-auto-open="auto_open"
t-att-data-check-full="check_full"
t-att-data-attach-to="attach_to"
- t-att-data-default-username="default_username">
+ t-att-data-default-username="default_username"
+ t-att-data-jitsi-server="jitsi_server_domain">
<button class="o_wjitsi_room_link btn btn-primary">Join the room</button>
</div>
</template>
diff --git a/addons/website_jitsi/views/res_config_settings.xml b/addons/website_jitsi/views/res_config_settings.xml
new file mode 100644
index 00000000000..e32abad4826
--- /dev/null
+++ b/addons/website_jitsi/views/res_config_settings.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<odoo>
+ <record id="res_config_settings_view_form" model="ir.ui.view">
+ <field name="name">res.config.settings.view.form.inherit.website.jitsi</field>
+ <field name="model">res.config.settings</field>
+ <field name="inherit_id" ref="website.res_config_settings_view_form" />
+ <field name="arch" type="xml">
+ <xpath expr="//div[@id='google_maps_setting']" position="after">
+ <div class="col-12 col-lg-6 o_setting_box">
+ <div class="o_setting_right_pane">
+ <label for="jitsi_server_domain"/>
+ <field name="jitsi_server_domain" placeholder="meet.jit.si"/>
+ </div>
+ </div>
+ </xpath>
+ </field>
+ </record>
+</odoo>