diff --git a/app/models/channel/filter/out_of_office_check.rb b/app/models/channel/filter/out_of_office_check.rb index c137c76f5..4fed2f13b 100644 --- a/app/models/channel/filter/out_of_office_check.rb +++ b/app/models/channel/filter/out_of_office_check.rb @@ -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 - mail[ 'x-zammad-out-of-office'.to_sym ] = true + # 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 diff --git a/test/unit/email_process_out_of_office_test.rb b/test/unit/email_process_out_of_office_test.rb index 2712b24b6..4a4b52573 100644 --- a/test/unit/email_process_out_of_office_test.rb +++ b/test/unit/email_process_out_of_office_test.rb @@ -131,7 +131,7 @@ Some Text" assert_equal(ticket.id, ticket_p.id) assert_equal('closed', ticket.state.name) - # normal follow up + # normal follow up email_raw_string = "From: me@example.com To: customer@example.com Subject: #{ticket.subject_build('some new subject - none')} @@ -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