[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#60191 Task-id: 2360504 X-original-commit: a748f66857d659db1a47d6c8ee6e4ac0c21d0361 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
committed by
Sébastien Theys
parent
dac1894d42
commit
5b98269eea
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user