From 7b01f6e538c90fd5a85c6813d91ba68e7ab57461 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 7 May 2018 14:30:39 +0200 Subject: [PATCH] Fixes issue #1996 - Use of wrong recipient if sender is also an agent (verify all recipient in to of article of there is a local address somewhere - not only the first one). --- .../javascripts/app/lib/app_post/utils.coffee | 4 +- public/assets/tests/html_utils.js | 39 +++++++++++++++++++ 2 files changed, 42 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 c4c9aa10a..25fb9a27f 100644 --- a/app/assets/javascripts/app/lib/app_post/utils.coffee +++ b/app/assets/javascripts/app/lib/app_post/utils.coffee @@ -994,7 +994,9 @@ class App.Utils if !_.isEmpty(article.to) recipients = App.Utils.parseAddressListLocal(article.to) if recipients && recipients[0] - recipientIsLocal = isLocalAddress(recipients[0]) + for localRecipient in recipients + recipientIsLocal = isLocalAddress(localRecipient) + break if recipientIsLocal is true # sender is local if senderIsLocal diff --git a/public/assets/tests/html_utils.js b/public/assets/tests/html_utils.js index 1faef7d8c..8097ceb88 100644 --- a/public/assets/tests/html_utils.js +++ b/public/assets/tests/html_utils.js @@ -2603,6 +2603,45 @@ test('check getRecipientArticle format', function() { verify = App.Utils.getRecipientArticle(ticket, article, agent, article.type, email_addresses, false) deepEqual(verify, result) + agent = { + login: 'login', + firstname: 'firstname', + lastname: 'lastname', + email: 'agent@example.com', + } + ticket = { + customer: agent, + } + article = { + message_id: 'message_id20', + created_by: agent, + type: { + name: 'email', + }, + sender: { + name: 'Agent', + }, + from: 'Agent ', + to: 'somebodyelse@example.com, Zammad ', + cc: '', + } + result = { + to: 'agent@example.com', + cc: '', + body: '', + in_reply_to: 'message_id20', + } + email_addresses = [ + { + email: 'zammad@example.com', + }, + { + email: 'zammad2@example.com', + } + ] + verify = App.Utils.getRecipientArticle(ticket, article, agent, article.type, email_addresses, false) + deepEqual(verify, result) + }); }