From 5b98269eea875010d49f1ba8b71987c488c76d8b Mon Sep 17 00:00:00 2001 From: Julien Giannone Date: Fri, 16 Oct 2020 14:09:53 +0000 Subject: [PATCH] [FIX] mail: no response on invalid command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fix allows to send an invalid command as a normal message to have it displayed in the messages list. closes odoo/odoo#60191 Task-id: 2360504 X-original-commit: a748f66857d659db1a47d6c8ee6e4ac0c21d0361 Signed-off-by: Alexandre Kühn (aku) --- addons/mail/static/src/models/composer/composer.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/mail/static/src/models/composer/composer.js b/addons/mail/static/src/models/composer/composer.js index 45e68546813..9d924eece6d 100644 --- a/addons/mail/static/src/models/composer/composer.js +++ b/addons/mail/static/src/models/composer/composer.js @@ -254,7 +254,7 @@ function factory(dependencies) { if (thread.model === 'mail.channel') { const command = this._getCommandFromText(body); Object.assign(postData, { - command, + command: command ? command.name : undefined, subtype_xmlid: 'mail.mt_comment' }); messageId = await this.async(() => this.env.services.rpc({ @@ -597,11 +597,12 @@ function factory(dependencies) { /** * @private * @param {string} content html content - * @returns {string|undefined} command, if any in the content + * @returns {mail.channel_command|undefined} command, if any in the content */ _getCommandFromText(content) { if (content.startsWith('/')) { - return content.substring(1).split(/\s/)[0]; + const firstWord = content.substring(1).split(/\s/)[0]; + return this.env.messaging.commands.find(command => command.name === firstWord); } return undefined; }