For auto response emails without T# in subject, find follow up by references header.

This commit is contained in:
Martin Edenhofer 2015-12-22 15:09:36 +01:00
parent 994c363484
commit 4df414f785
7 changed files with 73 additions and 28 deletions

View file

@ -2,10 +2,11 @@
module Channel::Filter::AutoResponseCheck
def self.run( _channel, mail )
def self.run(_channel, mail)
# if header is available, do not generate auto response
mail[ 'x-zammad-send-auto-response'.to_sym ] = false
mail[ 'x-zammad-is-auto-response'.to_sym ] = true
return if mail[ 'x-loop'.to_sym ] && mail[ 'x-loop'.to_sym ] =~ /(yes|true)/i
return if mail[ 'precedence'.to_sym ] && mail[ 'precedence'.to_sym ] =~ /bulk/i
@ -13,6 +14,7 @@ module Channel::Filter::AutoResponseCheck
return if mail[ 'x-auto-response-suppress'.to_sym ] && mail[ 'x-auto-response-suppress'.to_sym ] =~ /all/i
mail[ 'x-zammad-send-auto-response'.to_sym ] = true
mail[ 'x-zammad-is-auto-response'.to_sym ] = false
end
end

View file

@ -2,7 +2,7 @@
module Channel::Filter::BounceCheck
def self.run( _channel, mail )
def self.run(_channel, mail)
return if !mail[:mail_instance]
return if !mail[:mail_instance].bounced?

View file

@ -2,7 +2,7 @@
module Channel::Filter::FollowUpCheck
def self.run( _channel, mail )
def self.run(_channel, mail)
return if mail[ 'x-zammad-ticket-id'.to_sym ]
@ -39,7 +39,7 @@ module Channel::Filter::FollowUpCheck
end
# get ticket# from references
if setting.include?('references')
if setting.include?('references') || mail[ 'x-zammad-is-auto-response'.to_sym ] == true
# get all references 'References' + 'In-Reply-To'
references = ''

View file

@ -2,7 +2,7 @@
module Channel::Filter::OutOfOfficeCheck
def self.run( _channel, mail )
def self.run(_channel, mail)
mail[ 'x-zammad-out-of-office'.to_sym ] = false

View file

@ -3,14 +3,12 @@
# delete all X-Zammad header if channel is not trusted
module Channel::Filter::Trusted
def self.run( channel, mail )
def self.run(channel, mail)
# check if trust x-headers
if !channel[:trusted]
mail.each {|key, _value|
next if key !~ /^x-zammad/i
mail.delete(key)
}
end

View file

@ -7,10 +7,10 @@ class EmailProcessFollowUpTest < ActiveSupport::TestCase
ticket = Ticket.create(
title: 'follow up check',
group: Group.lookup( name: 'Users'),
group: Group.lookup(name: 'Users'),
customer_id: 2,
state: Ticket::State.lookup( name: 'new' ),
priority: Ticket::Priority.lookup( name: '2 normal' ),
state: Ticket::State.lookup(name: 'new'),
priority: Ticket::Priority.lookup(name: '2 normal'),
updated_by_id: 1,
created_by_id: 1,
)
@ -22,8 +22,8 @@ class EmailProcessFollowUpTest < ActiveSupport::TestCase
message_id: '<20150830145601.30.608882@edenhofer.zammad.com>',
body: 'some message article',
internal: false,
sender: Ticket::Article::Sender.where(name: 'Agent').first,
type: Ticket::Article::Type.where(name: 'email').first,
sender: Ticket::Article::Sender.lookup(name: 'Agent'),
type: Ticket::Article::Type.lookup(name: 'email'),
updated_by_id: 1,
created_by_id: 1,
)
@ -127,4 +127,48 @@ no reference "
assert_not_equal(ticket.id, ticket_p.id)
end
test 'process with follow up check - with auto responses and no T# in subject_build' do
ticket = Ticket.create(
title: 'follow up - with references follow up check',
group: Group.lookup(name: 'Users'),
customer_id: 2,
state: Ticket::State.lookup(name: 'closed'),
priority: Ticket::Priority.lookup(name: '2 normal'),
updated_by_id: 1,
created_by_id: 1,
)
article = Ticket::Article.create(
ticket_id: ticket.id,
from: 'some_sender@example.com',
to: 'some_recipient@example.com',
subject: 'follow up with references follow up check',
message_id: '<20151222145601.30.608881@edenhofer.zammad.com>',
body: 'some message with references follow up check',
internal: false,
sender: Ticket::Article::Sender.lookup(name: 'Agent'),
type: Ticket::Article::Type.lookup(name: 'email'),
updated_by_id: 1,
created_by_id: 1,
)
sleep 1
# auto response without T# in subject, find follow up by references header
email_raw_string = "From: bob@example.com
To: customer@example.com
Subject: =?ISO-8859-1?Q?AUTO=3A_Bob_Smith_ist_au=DFer_Haus=2E_=2F_is_out_of?=
=?ISO-8859-1?Q?_office=2E_=28R=FCckkehr_am_28=2E12=2E2015=29?=
In-Reply-To: <20251222081758.116249.983698@portal.znuny.com>
References: <OF9D1FD72A.878EF84E-ONC1257F22.003D7BB4-C1257F22.003F4503@example.com> <20151222145601.30.608881@edenhofer.zammad.com> <20251222081758.116249.983698@portal.znuny.com>
Message-ID: <OFD563742F.FC05EEAF-ONC1257F23.002DAE02@example.com>
Auto-Submitted: auto-replied
Some Text"
ticket_p, article_p, user_p, mail = Channel::EmailParser.new.process( {}, email_raw_string)
ticket = Ticket.find(ticket.id)
assert_equal(ticket.id, ticket_p.id)
assert_equal('open', ticket.state.name)
end
end

View file

@ -7,10 +7,10 @@ class EmailProcessOutOfOfficeTest < ActiveSupport::TestCase
ticket = Ticket.create(
title: 'ooo check - ms',
group: Group.lookup( name: 'Users'),
group: Group.lookup(name: 'Users'),
customer_id: 2,
state: Ticket::State.lookup( name: 'closed' ),
priority: Ticket::Priority.lookup( name: '2 normal' ),
state: Ticket::State.lookup(name: 'closed'),
priority: Ticket::Priority.lookup(name: '2 normal'),
updated_by_id: 1,
created_by_id: 1,
)
@ -22,8 +22,8 @@ class EmailProcessOutOfOfficeTest < ActiveSupport::TestCase
message_id: '<20150830145601.30.608881@edenhofer.zammad.com>',
body: 'some message bounce check',
internal: false,
sender: Ticket::Article::Sender.where(name: 'Agent').first,
type: Ticket::Article::Type.where(name: 'email').first,
sender: Ticket::Article::Sender.lookup(name: 'Agent'),
type: Ticket::Article::Type.lookup(name: 'email'),
updated_by_id: 1,
created_by_id: 1,
)
@ -93,10 +93,10 @@ Some Text"
ticket = Ticket.create(
title: 'ooo check - zimbra',
group: Group.lookup( name: 'Users'),
group: Group.lookup(name: 'Users'),
customer_id: 2,
state: Ticket::State.lookup( name: 'closed' ),
priority: Ticket::Priority.lookup( name: '2 normal' ),
state: Ticket::State.lookup(name: 'closed'),
priority: Ticket::Priority.lookup(name: '2 normal'),
updated_by_id: 1,
created_by_id: 1,
)
@ -108,8 +108,8 @@ Some Text"
message_id: '<20150830145601.30.608881@edenhofer.zammad.com>',
body: 'some message bounce check',
internal: false,
sender: Ticket::Article::Sender.where(name: 'Agent').first,
type: Ticket::Article::Type.where(name: 'email').first,
sender: Ticket::Article::Sender.lookup(name: 'Agent'),
type: Ticket::Article::Type.lookup(name: 'email'),
updated_by_id: 1,
created_by_id: 1,
)
@ -171,10 +171,10 @@ Some Text"
ticket = Ticket.create(
title: 'ooo check - cloud',
group: Group.lookup( name: 'Users'),
group: Group.lookup(name: 'Users'),
customer_id: 2,
state: Ticket::State.lookup( name: 'closed' ),
priority: Ticket::Priority.lookup( name: '2 normal' ),
state: Ticket::State.lookup(name: 'closed'),
priority: Ticket::Priority.lookup(name: '2 normal'),
updated_by_id: 1,
created_by_id: 1,
)
@ -186,8 +186,8 @@ Some Text"
message_id: '<20150830145601.30.608881@edenhofer.zammad.com>',
body: 'some message bounce check',
internal: false,
sender: Ticket::Article::Sender.where(name: 'Agent').first,
type: Ticket::Article::Type.where(name: 'email').first,
sender: Ticket::Article::Sender.lookup(name: 'Agent'),
type: Ticket::Article::Type.lookup(name: 'email'),
updated_by_id: 1,
created_by_id: 1,
)
@ -239,4 +239,5 @@ Some Text"
assert_equal('closed', ticket.state.name)
end
end