summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Giannone <jgi@odoo.com>2020-10-16 14:09:53 +0000
committerSébastien Theys <seb@odoo.com>2020-10-16 14:09:53 +0000
commita748f66857d659db1a47d6c8ee6e4ac0c21d0361 (patch)
tree082dfb73aae68132232bbec8d231365e19822c6e
parent8a889277d8fa0af8498964e264c781424f79e3d8 (diff)
[FIX] mail: no response on invalid command
This fix allows to send an invalid command as a normal message to have it displayed in the messages list. closes odoo/odoo#60165 Task-id: 2360504 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
-rw-r--r--addons/mail/static/src/models/composer/composer.js7
1 files 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;
}