Support correct article sender if sender address is system email address (needed to us correct reply recipients in ui).
This commit is contained in:
parent
f3e5412de4
commit
de9058e704
2 changed files with 40 additions and 17 deletions
|
@ -14,6 +14,7 @@ module Channel::Filter::ReplyToBasedSender
|
|||
result = Channel::EmailParser.sender_properties(reply_to)
|
||||
|
||||
if setting == 'as_sender_of_email'
|
||||
mail['raw-from'.to_sym] = mail['raw-reply-to'.to_sym]
|
||||
mail[:from] = reply_to
|
||||
mail[:from_email] = result[:from_email]
|
||||
mail[:from_local] = result[:from_local]
|
||||
|
@ -23,6 +24,7 @@ module Channel::Filter::ReplyToBasedSender
|
|||
end
|
||||
|
||||
if setting == 'as_sender_of_email_use_from_realname'
|
||||
mail['raw-from'.to_sym] = mail['raw-reply-to'.to_sym]
|
||||
mail[:from] = reply_to
|
||||
mail[:from_email] = result[:from_email]
|
||||
mail[:from_local] = result[:from_local]
|
||||
|
|
|
@ -4,8 +4,6 @@ require 'test_helper'
|
|||
class EmailProcessReplyToTest < ActiveSupport::TestCase
|
||||
|
||||
test 'normal processing' do
|
||||
|
||||
setting_orig = Setting.get('postmaster_sender_based_on_reply_to')
|
||||
Setting.set('postmaster_sender_based_on_reply_to', '')
|
||||
|
||||
email = "From: Bob Smith <marketing_tool@example.com>
|
||||
|
@ -16,19 +14,16 @@ Reply-To: replay_to_customer_process1@example.com
|
|||
Some Text"
|
||||
|
||||
ticket_p, article_p, user_p = Channel::EmailParser.new.process({}, email)
|
||||
assert_equal('Customer', article_p.sender.name)
|
||||
assert_equal('email', article_p.type.name)
|
||||
assert_equal('Bob Smith <marketing_tool@example.com>', article_p.from)
|
||||
assert_equal('replay_to_customer_process1@example.com', article_p.reply_to)
|
||||
assert_equal('marketing_tool@example.com', ticket_p.customer.email)
|
||||
assert_equal('Bob', ticket_p.customer.firstname)
|
||||
assert_equal('Smith', ticket_p.customer.lastname)
|
||||
|
||||
Setting.set('postmaster_sender_based_on_reply_to', setting_orig)
|
||||
|
||||
end
|
||||
|
||||
test 'normal processing - take reply to as customer' do
|
||||
|
||||
setting_orig = Setting.get('postmaster_sender_based_on_reply_to')
|
||||
Setting.set('postmaster_sender_based_on_reply_to', 'as_sender_of_email')
|
||||
|
||||
email = "From: Bob Smith <marketing_tool@example.com>
|
||||
|
@ -53,19 +48,16 @@ Reply-To: Some Name <replay_to_customer_process2-1@example.com>
|
|||
Some Text"
|
||||
|
||||
ticket_p, article_p, user_p = Channel::EmailParser.new.process({}, email)
|
||||
assert_equal('Customer', article_p.sender.name)
|
||||
assert_equal('email', article_p.type.name)
|
||||
assert_equal('Some Name <replay_to_customer_process2-1@example.com>', article_p.from)
|
||||
assert_equal('Some Name <replay_to_customer_process2-1@example.com>', article_p.reply_to)
|
||||
assert_equal('replay_to_customer_process2-1@example.com', ticket_p.customer.email)
|
||||
assert_equal('Some', ticket_p.customer.firstname)
|
||||
assert_equal('Name', ticket_p.customer.lastname)
|
||||
|
||||
Setting.set('postmaster_sender_based_on_reply_to', setting_orig)
|
||||
|
||||
end
|
||||
|
||||
test 'normal processing - take reply to as customer and use from as realname' do
|
||||
|
||||
setting_orig = Setting.get('postmaster_sender_based_on_reply_to')
|
||||
Setting.set('postmaster_sender_based_on_reply_to', 'as_sender_of_email_use_from_realname')
|
||||
|
||||
email = "From: Bob Smith <marketing_tool@example.com>
|
||||
|
@ -90,13 +82,42 @@ Reply-To: Some Name <replay_to_customer_process3-1@example.com>
|
|||
Some Text"
|
||||
|
||||
ticket_p, article_p, user_p = Channel::EmailParser.new.process({}, email)
|
||||
assert_equal('Customer', article_p.sender.name)
|
||||
assert_equal('email', article_p.type.name)
|
||||
assert_equal('Some Name <replay_to_customer_process3-1@example.com>', article_p.from)
|
||||
assert_equal('Some Name <replay_to_customer_process3-1@example.com>', article_p.reply_to)
|
||||
assert_equal('replay_to_customer_process3-1@example.com', ticket_p.customer.email)
|
||||
assert_equal('Bob', ticket_p.customer.firstname)
|
||||
assert_equal('Smith', ticket_p.customer.lastname)
|
||||
end
|
||||
|
||||
Setting.set('postmaster_sender_based_on_reply_to', setting_orig)
|
||||
test 'normal processing - take reply to as customer and sender is system address' do
|
||||
|
||||
Setting.set('postmaster_sender_based_on_reply_to', 'as_sender_of_email')
|
||||
|
||||
EmailAddress.create!(
|
||||
realname: 'address #1',
|
||||
email: 'marketing_tool@example.com',
|
||||
active: true,
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
|
||||
email = "From: Marketing Tool <marketing_tool@example.com>
|
||||
To: zammad@example.com
|
||||
Subject: some new subject
|
||||
Reply-To: replay_to_customer_process2@example.com
|
||||
|
||||
Some Text"
|
||||
|
||||
ticket_p, article_p, user_p = Channel::EmailParser.new.process({}, email)
|
||||
assert_equal('Customer', article_p.sender.name)
|
||||
assert_equal('email', article_p.type.name)
|
||||
assert_equal('replay_to_customer_process2@example.com', article_p.from)
|
||||
assert_equal('replay_to_customer_process2@example.com', article_p.reply_to)
|
||||
assert_equal('replay_to_customer_process2@example.com', ticket_p.customer.email)
|
||||
assert_equal('', ticket_p.customer.firstname)
|
||||
assert_equal('', ticket_p.customer.lastname)
|
||||
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue