From 2cab5742b2a93f6639372138eb8f20d88df69bea Mon Sep 17 00:00:00 2001 From: Mantas Date: Fri, 18 Jun 2021 14:07:14 +0300 Subject: [PATCH] Fixes #2551 - Reply-to header ignored if from contains a system address --- .../javascripts/app/lib/app_post/utils.coffee | 2 +- public/assets/tests/html_utils.js | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/app/lib/app_post/utils.coffee b/app/assets/javascripts/app/lib/app_post/utils.coffee index 70eef244e..3d506bed1 100644 --- a/app/assets/javascripts/app/lib/app_post/utils.coffee +++ b/app/assets/javascripts/app/lib/app_post/utils.coffee @@ -1253,7 +1253,7 @@ class App.Utils # sender is local if senderIsLocal - articleNew.to = article.to + articleNew.to = article.reply_to || article.to # sender is agent - sent via system else if article.sender.name is 'Agent' && article_created_by_email && article.from && article.from.toString().toLowerCase().match(article_created_by_email) && !recipientIsLocal diff --git a/public/assets/tests/html_utils.js b/public/assets/tests/html_utils.js index b35771815..c44b0c9d2 100644 --- a/public/assets/tests/html_utils.js +++ b/public/assets/tests/html_utils.js @@ -3142,6 +3142,52 @@ test('check getRecipientArticle format', function() { verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type) deepEqual(verify, result) + // https://github.com/zammad/zammad/issues/2551 + // If "From:" is local address and "Reply-To:" is available, use it + + 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: 'email', + }, + sender: { + name: 'Customer', + }, + from: 'article lastname ', + to: 'some group', + reply_to: 'asd@example.com', + message_id: 'message_id22', + created_by: { + login: 'login', + firstname: 'firstname', + lastname: 'lastname', + email: 'article_created_by@example.com', + }, + } + email_addresses = [{ email: 'article_customer@example.com'}] + result = { + to: 'asd@example.com', + cc: '', + body: '', + in_reply_to: 'message_id22', + } + verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type, email_addresses) + deepEqual(verify, result) + }); test("contentTypeCleanup", function() {