Also detect gmail vacation emails based on "vacation" in subject. Fixes issue#193.
This commit is contained in:
parent
9797dbb1d4
commit
9edcf47edb
2 changed files with 61 additions and 0 deletions
|
@ -27,6 +27,11 @@ module Channel::Filter::OutOfOfficeCheck
|
||||||
mail[ 'x-zammad-out-of-office'.to_sym ] = true
|
mail[ 'x-zammad-out-of-office'.to_sym ] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# gmail check out of office characteristics
|
||||||
|
if mail[ 'auto-submitted'.to_sym ] =~ /auto-replied/i && mail[ 'subject'.to_sym ] =~ /vacation/i
|
||||||
|
mail[ 'x-zammad-out-of-office'.to_sym ] = true
|
||||||
|
end
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -240,4 +240,60 @@ Some Text"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test 'process with out of office check - gmail' do
|
||||||
|
|
||||||
|
ticket = Ticket.create(
|
||||||
|
title: 'ooo check - gmail',
|
||||||
|
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: 'ooo check',
|
||||||
|
message_id: '<20150830145601.30.608881@edenhofer.zammad.com>',
|
||||||
|
body: 'some message bounce 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
|
||||||
|
|
||||||
|
# gmail out of office example #1
|
||||||
|
email_raw_string = "From: me@example.com
|
||||||
|
To: customer@example.com
|
||||||
|
Subject: vacation: #{ticket.subject_build('some new subject 1')}
|
||||||
|
Precedence: bulk
|
||||||
|
X-Autoreply: yes
|
||||||
|
Auto-Submitted: auto-replied
|
||||||
|
|
||||||
|
Some Text"
|
||||||
|
|
||||||
|
ticket_p, article_p, user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
||||||
|
assert_equal(true, mail['x-zammad-out-of-office'.to_sym])
|
||||||
|
ticket = Ticket.find(ticket.id)
|
||||||
|
assert_equal(ticket.id, ticket_p.id)
|
||||||
|
assert_equal('closed', ticket.state.name)
|
||||||
|
|
||||||
|
# normal follow up
|
||||||
|
email_raw_string = "From: me@example.com
|
||||||
|
To: customer@example.com
|
||||||
|
Subject: #{ticket.subject_build('some new subject - none')}
|
||||||
|
|
||||||
|
Some Text 2"
|
||||||
|
|
||||||
|
ticket_p, article_p, user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
||||||
|
assert_equal(false, mail['x-zammad-out-of-office'.to_sym])
|
||||||
|
ticket = Ticket.find(ticket.id)
|
||||||
|
assert_equal(ticket.id, ticket_p.id)
|
||||||
|
assert_equal('open', ticket_p.state.name)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue