Added out of office detection support for icloud.

This commit is contained in:
Martin Edenhofer 2015-09-22 22:30:38 +02:00
parent 8a2dd87861
commit b753ba5396
2 changed files with 83 additions and 4 deletions

View file

@ -15,11 +15,18 @@ module Channel::Filter::OutOfOfficeCheck
return
end
# check zimbra out of office characteristics
if mail[ 'auto-submitted'.to_sym ]
return if mail[ 'auto-submitted'.to_sym ] !~ /vacation/i
# check zimbra out of office characteristics
if mail[ 'auto-submitted'.to_sym ] =~ /vacation/i
mail[ 'x-zammad-out-of-office'.to_sym ] = true
end
# check cloud out of office characteristics
if mail[ 'auto-submitted'.to_sym ] =~ /auto-replied;\sowner-email=/i
mail[ 'x-zammad-out-of-office'.to_sym ] = true
end
return
end

View file

@ -167,4 +167,76 @@ Some Text"
end
test 'process with out of office check - cloud' do
ticket = Ticket.create(
title: 'ooo check - cloud',
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.where(name: 'Agent').first,
type: Ticket::Article::Type.where(name: 'email').first,
updated_by_id: 1,
created_by_id: 1,
)
sleep 1
# exchange out of office example #1
email_raw_string = "From: me@example.com
To: customer@example.com
Subject: #{ticket.subject_build('some new subject 1')}
Auto-submitted: auto-replied; owner-email=\"me@example.com\"
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)
ticket = Ticket.find(ticket.id)
ticket.state = Ticket::State.lookup(name: 'closed')
ticket.save
# exchange out of office example #2
email_raw_string = "From: me@example.com
To: customer@example.com
Subject: #{ticket.subject_build('some new subject 2')}
Auto-submitted: auto-replied; owner-email=\"me@example.com\"
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)
end
end