From 24c3095532420ef8dd743aab4a7976ef4d7fef53 Mon Sep 17 00:00:00 2001 From: abd-msyukyu-odoo Date: Thu, 29 Jun 2023 18:01:48 +0000 Subject: [PATCH] [IMP] web_editor: allow collaboration for portal users Encapsulate the `mail` ICE servers availability check in an overridable function, since the hack does not work in a portal context, but Knowledge portal users should be allowed to use the collaborative feature. Knowledge will override the session check by always returning true, since mail is a dependency of Knowledge and is therefore always installed with it. Allow access to the edition channel for portal users. task-3378266 X-original-commit: odoo/odoo@03e1148ac994f85b416186890c66990c869b394e Part-of: odoo/odoo#128962 --- addons/web_editor/models/ir_websocket.py | 2 +- addons/web_editor/static/src/js/wysiwyg/wysiwyg.js | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/web_editor/models/ir_websocket.py b/addons/web_editor/models/ir_websocket.py index a374890f9ae..5fb70667b26 100644 --- a/addons/web_editor/models/ir_websocket.py +++ b/addons/web_editor/models/ir_websocket.py @@ -23,7 +23,7 @@ class IrWebsocket(models.AbstractModel): res_id = int(match[3]) # Verify access to the edition channel. - if not self.env.user._is_internal(): + if self.env.user._is_public(): raise AccessDenied() document = self.env[model_name].browse([res_id]) diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 8b704db8d35..096866b57b8 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -324,8 +324,7 @@ export class Wysiwyg extends Component { let editorCollaborationOptions; if ( options.collaborationChannel && - // Hack: check if mail module is installed. - session.notification_type + this._hasICEServers() ) { editorCollaborationOptions = this.setupCollaboration(options.collaborationChannel); if (this.options.collaborativeTrigger === 'start') { @@ -2864,6 +2863,12 @@ export class Wysiwyg extends Component { _bindOnBlur() { this.$editable.on('blur', this._onBlur); } + + _hasICEServers() { + // Hack: check if mail module is installed. + session.notification_type + } + /** * Saves a base64 encoded image as an attachment. * Relies on _saveModifiedImage being called after it for webp.