Added out of office detection for zimbra.
This commit is contained in:
parent
afb956ae00
commit
dd444f63e0
2 changed files with 95 additions and 6 deletions
|
@ -7,11 +7,22 @@ module Channel::Filter::OutOfOfficeCheck
|
||||||
mail[ 'x-zammad-out-of-office'.to_sym ] = false
|
mail[ 'x-zammad-out-of-office'.to_sym ] = false
|
||||||
|
|
||||||
# check ms out of office characteristics
|
# check ms out of office characteristics
|
||||||
return if !mail[ 'x-auto-response-suppress'.to_sym ]
|
if mail[ 'x-auto-response-suppress'.to_sym ]
|
||||||
return if mail[ 'x-auto-response-suppress'.to_sym ] !~ /all/i
|
return if mail[ 'x-auto-response-suppress'.to_sym ] !~ /all/i
|
||||||
return if !mail[ 'x-ms-exchange-inbox-rules-loop'.to_sym ]
|
return if !mail[ 'x-ms-exchange-inbox-rules-loop'.to_sym ]
|
||||||
|
|
||||||
mail[ 'x-zammad-out-of-office'.to_sym ] = true
|
mail[ 'x-zammad-out-of-office'.to_sym ] = true
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
# check zimbra out of office characteristics
|
||||||
|
if mail[ 'auto-submitted'.to_sym ]
|
||||||
|
return if mail[ 'auto-submitted'.to_sym ] !~ /vacation/i
|
||||||
|
|
||||||
|
mail[ 'x-zammad-out-of-office'.to_sym ] = true
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,10 +3,10 @@ require 'test_helper'
|
||||||
|
|
||||||
class EmailProcessOutOfOfficeTest < ActiveSupport::TestCase
|
class EmailProcessOutOfOfficeTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
test 'process with out of office check' do
|
test 'process with out of office check - ms' do
|
||||||
|
|
||||||
ticket = Ticket.create(
|
ticket = Ticket.create(
|
||||||
title: 'ooo check',
|
title: 'ooo check - ms',
|
||||||
group: Group.lookup( name: 'Users'),
|
group: Group.lookup( name: 'Users'),
|
||||||
customer_id: 2,
|
customer_id: 2,
|
||||||
state: Ticket::State.lookup( name: 'closed' ),
|
state: Ticket::State.lookup( name: 'closed' ),
|
||||||
|
@ -79,6 +79,84 @@ X-MS-Exchange-Inbox-Rules-Loop: aaa.bbb@example.com
|
||||||
X-MS-TNEF-Correlator:
|
X-MS-TNEF-Correlator:
|
||||||
x-exclaimer-md-config: 8c10826d-4052-4c5c-a8e8-e09011276827
|
x-exclaimer-md-config: 8c10826d-4052-4c5c-a8e8-e09011276827
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
test 'process with out of office check - zimbra' do
|
||||||
|
|
||||||
|
ticket = Ticket.create(
|
||||||
|
title: 'ooo check - zimbra',
|
||||||
|
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 (zimbra; vacation)
|
||||||
|
Precedence: bulk
|
||||||
|
X-Mailer: Zimbra 7.1.3_GA_3346
|
||||||
|
|
||||||
|
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')}
|
||||||
|
X-Mailer: Zimbra 7.1.3_GA_3346
|
||||||
|
|
||||||
|
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 (zimbra; vacation)
|
||||||
|
Precedence: bulk
|
||||||
|
X-Mailer: Zimbra 7.1.3_GA_3346
|
||||||
|
|
||||||
Some Text"
|
Some Text"
|
||||||
|
|
||||||
ticket_p, article_p, user_p, mail = Channel::EmailParser.new.process( {}, email_raw_string)
|
ticket_p, article_p, user_p, mail = Channel::EmailParser.new.process( {}, email_raw_string)
|
||||||
|
|
Loading…
Reference in a new issue