From e21d6c541457b57d99913792e365ab731fcd3bc3 Mon Sep 17 00:00:00 2001 From: Mantas Masalskis Date: Thu, 11 Nov 2021 15:31:39 +0100 Subject: [PATCH] Fixes #3824 - Email address not shown inside forwarded email --- .../app/lib/app_post/full_quote_header.coffee | 10 +++--- .../ticket/update/full_quote_header_spec.rb | 33 +++++++++++++++---- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/app/lib/app_post/full_quote_header.coffee b/app/assets/javascripts/app/lib/app_post/full_quote_header.coffee index 63b7a7761..712ca9e2e 100644 --- a/app/assets/javascripts/app/lib/app_post/full_quote_header.coffee +++ b/app/assets/javascripts/app/lib/app_post/full_quote_header.coffee @@ -28,7 +28,7 @@ class App.FullQuoteHeader @fullQuoteHeaderForwardTo: (article) -> if article.type.name is 'email' || article.type.name is 'web' - @fullQuoteHeaderEnsurePrivacy(article.to) || article.to + @fullQuoteHeaderEnsureMultiPrivacy(article.to) else if article.sender.name is 'Customer' && article.type.name is 'phone' if email_address_id = App.Group.findByAttribute('name', article.to)?.email_address_id App.EmailAddress.find(email_address_id).displayName() @@ -36,15 +36,17 @@ class App.FullQuoteHeader article.to else if article.sender.name is 'Agent' && article.type.name is 'phone' ticket = App.Ticket.find article.ticket_id - @fullQuoteHeaderEnsurePrivacy(ticket.customer_id) || @fullQuoteHeaderEnsurePrivacy(article.to) || article.to + @fullQuoteHeaderEnsurePrivacy(ticket.customer_id) || @fullQuoteHeaderEnsureMultiPrivacy(article.to) else article.to @fullQuoteHeaderForwardCC: (article) -> return if !article.cc - article - .cc + @fullQuoteHeaderEnsureMultiPrivacy(article.cc) + + @fullQuoteHeaderEnsureMultiPrivacy: (input) -> + input .split(',') .map (elem) -> elem.trim() diff --git a/spec/system/ticket/update/full_quote_header_spec.rb b/spec/system/ticket/update/full_quote_header_spec.rb index 95f24fb18..567ea2eee 100644 --- a/spec/system/ticket/update/full_quote_header_spec.rb +++ b/spec/system/ticket/update/full_quote_header_spec.rb @@ -21,7 +21,7 @@ RSpec.describe 'Ticket > Update > Full Quote Header', current_user_id: -> { curr context 'when "ui_ticket_zoom_article_email_full_quote_header" is enabled' do let(:full_quote_header_setting) { true } - it 'includes OP when forwarding' do + it 'includes sender when forwarding' do within(:active_content) do click_forward @@ -31,7 +31,7 @@ RSpec.describe 'Ticket > Update > Full Quote Header', current_user_id: -> { curr end end - it 'includes OP when replying' do + it 'includes sender when replying' do within(:active_content) do highlight_and_click_reply @@ -41,7 +41,7 @@ RSpec.describe 'Ticket > Update > Full Quote Header', current_user_id: -> { curr end end - it 'includes OP when article visibility toggled' do + it 'includes sender when article visibility toggled' do within(:active_content) do set_internal highlight_and_click_reply @@ -55,7 +55,7 @@ RSpec.describe 'Ticket > Update > Full Quote Header', current_user_id: -> { curr context 'when customer is agent' do let(:customer) { create(:agent) } - it 'includes OP without email when forwarding' do + it 'includes sender without email when forwarding' do within(:active_content) do click_forward @@ -66,13 +66,32 @@ RSpec.describe 'Ticket > Update > Full Quote Header', current_user_id: -> { curr end end + # https://github.com/zammad/zammad/issues/3824 + context 'when TO contains multiple senders and one of them is a known Zammad user' do + let(:customer) { create(:customer) } + let(:to_1) { "#{customer.fullname} <#{customer.email}>" } + let(:to_2) { 'Example Two ' } + + let(:ticket_article) { create(:ticket_article, ticket: ticket, to: [to_1, to_2].join(', ')) } + + it 'includes all TO email address' do + within(:active_content) do + click_forward + + within(:richtext) do + expect(page).to have_text(to_1).and(have_text(to_2)) + end + end + end + end + context 'ticket is created by agent on behalf of customer' do let(:agent) { create(:agent) } let(:current_user) { agent } let(:ticket) { create(:ticket, group: group, title: 'Created by agent on behalf of a customer', customer: customer) } let(:ticket_article) { create(:ticket_article, ticket: ticket, from: 'Created by agent on behalf of a customer', origin_by_id: customer.id) } - it 'includes OP without email when replying' do + it 'includes sender without email when replying' do within(:active_content) do highlight_and_click_reply @@ -87,7 +106,7 @@ RSpec.describe 'Ticket > Update > Full Quote Header', current_user_id: -> { curr context 'when "ui_ticket_zoom_article_email_full_quote_header" is disabled' do let(:full_quote_header_setting) { false } - it 'does not include OP when forwarding' do + it 'does not include sender when forwarding' do within(:active_content) do click_forward @@ -97,7 +116,7 @@ RSpec.describe 'Ticket > Update > Full Quote Header', current_user_id: -> { curr end end - it 'does not include OP when replying' do + it 'does not include sender when replying' do within(:active_content) do highlight_and_click_reply