Fixed issue #2184 - Reply does not work as expected (fixes #2184)

This commit is contained in:
Billy Zhou 2018-10-02 06:50:04 +02:00
parent 381e00b74f
commit 8fb46b0448
2 changed files with 102 additions and 6 deletions

View file

@ -1021,14 +1021,14 @@ class App.Utils
if type.name is 'phone'
# inbound call
# the article we are replying to is an outbound call
if article.sender.name is 'Agent'
if article.to
if article.to?.match(/@/)
articleNew.to = article.to
# outbound call
else if article.to
articleNew.to = article.to
# the article we are replying to is an incoming call
else if article.from?.match(/@/)
articleNew.to = article.from
# if sender is customer but in article.from is no email, try to get
# customers email via customer user

View file

@ -2100,7 +2100,7 @@ test('check getRecipientArticle format', function() {
},
}
result = {
to: customer.email,
to: 'customer@example.com',
cc: '',
body: '',
in_reply_to: 'message_id3',
@ -2915,6 +2915,102 @@ test('check getRecipientArticle format', function() {
verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
deepEqual(verify, result)
// Regression test for issue #2184
// Case 1
// 1. Create a "Received Call" Ticket for article_customer
// 2. Change the Customer of the ticket to ticket_customer (but article.from still points to article_customer)
// 3. Reply to the first Article
// Recipient SHOULD BE Article.from
var article_customer = {
login: 'login',
firstname: 'article',
lastname: 'lastname',
email: 'article_customer@example.com',
}
var ticket_customer = {
login: 'login2',
firstname: 'ticket',
lastname: 'lastname',
email: 'ticket_customer@example.com',
}
ticket = {
customer: ticket_customer,
}
article = {
type: {
name: 'phone',
},
sender: {
name: 'Customer',
},
from: article_customer.email,
to: 'some group',
message_id: 'message_id22',
created_by: {
login: 'login',
firstname: 'firstname',
lastname: 'lastname',
email: 'article_created_by@example.com',
},
}
result = {
to: 'article_customer@example.com',
cc: '',
body: '',
in_reply_to: 'message_id22',
}
verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
deepEqual(verify, result)
// Regression test for issue #2184
// Case 2
// 1. Create a "Outbound Call" Ticket for article_customer
// 2. Change the Customer of the Ticket to ticket_customer (but article.to still points to article_customer)
// 3. Reply to the first Article
// Recipient SHOULD BE Article.to
article_customer = {
login: 'login',
firstname: 'article',
lastname: 'lastname',
email: 'article_customer@example.com',
}
ticket_customer = {
login: 'login2',
firstname: 'ticket',
lastname: 'lastname',
email: 'ticket_customer@example.com',
}
ticket = {
customer: ticket_customer,
}
article = {
type: {
name: 'phone',
},
sender: {
name: 'Agent',
},
from: 'agent1@example.com',
to: article_customer.email,
message_id: 'message_id23',
created_by: {
login: 'login',
firstname: 'firstname',
lastname: 'lastname',
email: 'article_created_by@example.com',
},
}
result = {
to: 'article_customer@example.com',
cc: '',
body: '',
in_reply_to: 'message_id23',
}
verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
deepEqual(verify, result)
});
test("contentTypeCleanup", function() {