[FIX] mail: Cannot send new message from Event Track

When the Speaker address is False, it crashed.

opw:805361
This commit is contained in:
Goffin Simon
2018-01-16 15:58:41 +01:00
parent 5e474bb3f9
commit 73c9b3d014
2 changed files with 13 additions and 11 deletions
+3 -3
View File
@@ -111,7 +111,7 @@ var ChatterComposer = composer.BasicComposer.extend({
.done(function (suggested_recipients) {
var thread_recipients = suggested_recipients[self.context.default_res_id];
_.each(thread_recipients, function (recipient) {
var parsed_email = utils.parse_email(recipient[1]);
var parsed_email = recipient[1] && utils.parse_email(recipient[1]);
if (_.indexOf(email_addresses, parsed_email[1]) === -1) {
self.suggested_partners.push({
checked: true,
@@ -188,8 +188,8 @@ var ChatterComposer = composer.BasicComposer.extend({
context: {
force_email: true,
ref: "compound_context",
default_name: parsed_email[0],
default_email: parsed_email[1],
default_name: parsed_email && parsed_email[0],
default_email: parsed_email && parsed_email[1],
},
title: _t("Please complete partner's informations"),
disable_multiple_selection: true,
+10 -8
View File
@@ -101,15 +101,17 @@ function inline (node, transform_children) {
// Parses text to find email: Tagada <address@mail.fr> -> [Tagada, address@mail.fr] or False
function parse_email (text) {
var result = text.match(/(.*)<(.*@.*)>/);
if (result) {
return [_.str.trim(result[1]), _.str.trim(result[2])];
if (text){
var result = text.match(/(.*)<(.*@.*)>/);
if (result) {
return [_.str.trim(result[1]), _.str.trim(result[2])];
}
result = text.match(/(.*@.*)/);
if (result) {
return [_.str.trim(result[1]), _.str.trim(result[1])];
}
return [text, false];
}
result = text.match(/(.*@.*)/);
if (result) {
return [_.str.trim(result[1]), _.str.trim(result[1])];
}
return [text, false];
}
// Replaces textarea text into html text (add <p>, <a>)