From d3a3eed7a42d9918418ba3a949db84d518330483 Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Wed, 26 Apr 2017 16:50:57 +0200 Subject: [PATCH] Fixed issue #203 - Mailprocessing: Reply-To header are ignored. --- .../app/controllers/ticket_zoom/article_actions.coffee | 5 ++++- .../app/views/ticket_zoom/article_view.jst.eco | 6 ++++++ app/models/channel/email_parser.rb | 9 +++++---- db/migrate/20120101000010_create_ticket.rb | 2 +- db/migrate/20170426135500_add_reply_to.rb | 9 +++++++++ test/unit/email_parser_test.rb | 1 + 6 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 db/migrate/20170426135500_add_reply_to.rb diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/article_actions.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/article_actions.coffee index 71a60c883..c1d50f842 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/article_actions.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_actions.coffee @@ -340,7 +340,10 @@ class App.TicketZoomArticleActions extends App.Controller if article.sender.name is 'Agent' && !article.from.match(user.email) articleNew.to = article.to else - articleNew.to = article.from + if article.reply_to + articleNew.to = article.reply_to + else + articleNew.to = article.from # if sender is customer but in article.from is no email, try to get # customers email via customer user diff --git a/app/assets/javascripts/app/views/ticket_zoom/article_view.jst.eco b/app/assets/javascripts/app/views/ticket_zoom/article_view.jst.eco index 1ed4685a5..2f553018d 100644 --- a/app/assets/javascripts/app/views/ticket_zoom/article_view.jst.eco +++ b/app/assets/javascripts/app/views/ticket_zoom/article_view.jst.eco @@ -7,6 +7,12 @@
<%- @AddressLine(@article.from) %>
<% end %> + <% if @article.reply_to: %> +
+ + +
+ <% end %> <% if @article.to: %>
diff --git a/app/models/channel/email_parser.rb b/app/models/channel/email_parser.rb index 6e092f5a7..724ddacc5 100644 --- a/app/models/channel/email_parser.rb +++ b/app/models/channel/email_parser.rb @@ -396,20 +396,20 @@ class Channel::EmailParser =begin parser = Channel::EmailParser.new - ticket, article, user = parser.process(channel, email_raw_string) + ticket, article, user, mail = parser.process(channel, email_raw_string) returns - [ticket, article, user] + [ticket, article, user, mail] do not raise an exception - e. g. if used by scheduler parser = Channel::EmailParser.new - ticket, article, user = parser.process(channel, email_raw_string, false) + ticket, article, user, mail = parser.process(channel, email_raw_string, false) returns - [ticket, article, user] || false + [ticket, article, user, mail] || false =end @@ -564,6 +564,7 @@ returns content_type: mail[:content_type], body: mail[:body], from: mail[:from], + reply_to: mail[:"reply-to"], to: mail[:to], cc: mail[:cc], subject: mail[:subject], diff --git a/db/migrate/20120101000010_create_ticket.rb b/db/migrate/20120101000010_create_ticket.rb index 6cca4ada3..fce58eb82 100644 --- a/db/migrate/20120101000010_create_ticket.rb +++ b/db/migrate/20120101000010_create_ticket.rb @@ -155,7 +155,7 @@ class CreateTicket < ActiveRecord::Migration t.column :to, :string, limit: 3000, null: true t.column :cc, :string, limit: 3000, null: true t.column :subject, :string, limit: 3000, null: true - # t.column :reply_to, :string, :limit => 3000, :null => true + t.column :reply_to, :string, limit: 3000, null: true t.column :message_id, :string, limit: 3000, null: true t.column :message_id_md5, :string, limit: 32, null: true t.column :in_reply_to, :string, limit: 3000, null: true diff --git a/db/migrate/20170426135500_add_reply_to.rb b/db/migrate/20170426135500_add_reply_to.rb new file mode 100644 index 000000000..8407f7782 --- /dev/null +++ b/db/migrate/20170426135500_add_reply_to.rb @@ -0,0 +1,9 @@ +class AddReplyTo < ActiveRecord::Migration + def up + + # return if it's a new setup + return if !Setting.find_by(name: 'system_init_done') + + add_column :ticket_articles, :reply_to, :string, limit: 3000 + end +end diff --git a/test/unit/email_parser_test.rb b/test/unit/email_parser_test.rb index 7ce04a597..14a93a1dd 100644 --- a/test/unit/email_parser_test.rb +++ b/test/unit/email_parser_test.rb @@ -362,6 +362,7 @@ Registergericht / Commercial Register of the Local Court: HRB 0000 AG Hof', }, ], params: { + "reply-to": 'serviceteam@cylex.de', from: 'CYLEX Newsletter ', from_email: 'carina.merkant@cylex.de', from_display_name: 'CYLEX Newsletter',