Private me issue2219 reopen delivery delay message
This commit is contained in:
parent
2774bc207d
commit
925ff56066
5 changed files with 161 additions and 6 deletions
|
@ -0,0 +1,17 @@
|
||||||
|
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
|
module Channel::Filter::BounceDeliveryTemporaryFailed
|
||||||
|
|
||||||
|
def self.run(_channel, mail)
|
||||||
|
return if !mail[:mail_instance]
|
||||||
|
return if !mail[:attachments]
|
||||||
|
return if mail[:mail_instance].action != 'delayed'
|
||||||
|
return if mail[:mail_instance].retryable? != true
|
||||||
|
return if mail[:mail_instance].error_status != '4.4.1'
|
||||||
|
|
||||||
|
# if header is available, do change current ticket state
|
||||||
|
mail['x-zammad-out-of-office'.to_sym] = true
|
||||||
|
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,19 @@
|
||||||
|
class SettingDeliveryTemporaryFailed < ActiveRecord::Migration[5.1]
|
||||||
|
def up
|
||||||
|
|
||||||
|
# return if it's a new setup
|
||||||
|
return if !Setting.find_by(name: 'system_init_done')
|
||||||
|
|
||||||
|
Setting.create_if_not_exists(
|
||||||
|
title: 'Defines postmaster filter.',
|
||||||
|
name: '0955_postmaster_filter_bounce_delivery_temporary_failed',
|
||||||
|
area: 'Postmaster::PreFilter',
|
||||||
|
description: 'Defines postmaster filter to identify postmaster bounced - reopen ticket on permanent temporary failed.',
|
||||||
|
options: {},
|
||||||
|
state: 'Channel::Filter::BounceDeliveryTemporaryFailed',
|
||||||
|
frontend: false
|
||||||
|
)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -3211,6 +3211,15 @@ Setting.create_if_not_exists(
|
||||||
state: 'Channel::Filter::BounceDeliveryPermanentFailed',
|
state: 'Channel::Filter::BounceDeliveryPermanentFailed',
|
||||||
frontend: false
|
frontend: false
|
||||||
)
|
)
|
||||||
|
Setting.create_if_not_exists(
|
||||||
|
title: 'Defines postmaster filter.',
|
||||||
|
name: '0955_postmaster_filter_bounce_delivery_temporary_failed',
|
||||||
|
area: 'Postmaster::PreFilter',
|
||||||
|
description: 'Defines postmaster filter to identify postmaster bounced - reopen ticket on permanent temporary failed.',
|
||||||
|
options: {},
|
||||||
|
state: 'Channel::Filter::BounceDeliveryTemporaryFailed',
|
||||||
|
frontend: false
|
||||||
|
)
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Defines postmaster filter.',
|
title: 'Defines postmaster filter.',
|
||||||
name: '1000_postmaster_filter_database_check',
|
name: '1000_postmaster_filter_database_check',
|
||||||
|
|
|
@ -57,7 +57,7 @@ class EmailProcessBounceDeliveryPermanentFailedTest < ActiveSupport::TestCase
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
)
|
)
|
||||||
|
|
||||||
ticket = Ticket.create(
|
ticket = Ticket.create!(
|
||||||
title: 'bounce check',
|
title: 'bounce check',
|
||||||
group: Group.lookup(name: 'Users'),
|
group: Group.lookup(name: 'Users'),
|
||||||
customer: customer1,
|
customer: customer1,
|
||||||
|
@ -66,7 +66,7 @@ class EmailProcessBounceDeliveryPermanentFailedTest < ActiveSupport::TestCase
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
article = Ticket::Article.create(
|
article = Ticket::Article.create!(
|
||||||
ticket_id: ticket.id,
|
ticket_id: ticket.id,
|
||||||
from: 'some_sender@example.com',
|
from: 'some_sender@example.com',
|
||||||
to: 'some_recipient@example.com',
|
to: 'some_recipient@example.com',
|
||||||
|
@ -83,7 +83,7 @@ class EmailProcessBounceDeliveryPermanentFailedTest < ActiveSupport::TestCase
|
||||||
assert_equal('new', ticket.state.name)
|
assert_equal('new', ticket.state.name)
|
||||||
assert_equal(2, ticket.articles.count)
|
assert_equal(2, ticket.articles.count)
|
||||||
|
|
||||||
article = Ticket::Article.create(
|
article = Ticket::Article.create!(
|
||||||
ticket_id: ticket.id,
|
ticket_id: ticket.id,
|
||||||
from: 'some_sender@example.com',
|
from: 'some_sender@example.com',
|
||||||
to: customer1.email,
|
to: customer1.email,
|
||||||
|
@ -164,7 +164,7 @@ class EmailProcessBounceDeliveryPermanentFailedTest < ActiveSupport::TestCase
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
)
|
)
|
||||||
|
|
||||||
ticket = Ticket.create(
|
ticket = Ticket.create!(
|
||||||
title: 'bounce check',
|
title: 'bounce check',
|
||||||
group: Group.lookup(name: 'Users'),
|
group: Group.lookup(name: 'Users'),
|
||||||
customer: customer2,
|
customer: customer2,
|
||||||
|
@ -173,7 +173,7 @@ class EmailProcessBounceDeliveryPermanentFailedTest < ActiveSupport::TestCase
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
article = Ticket::Article.create(
|
article = Ticket::Article.create!(
|
||||||
ticket_id: ticket.id,
|
ticket_id: ticket.id,
|
||||||
from: 'some_sender@example.com',
|
from: 'some_sender@example.com',
|
||||||
to: 'some_recipient@example.com',
|
to: 'some_recipient@example.com',
|
||||||
|
@ -190,7 +190,7 @@ class EmailProcessBounceDeliveryPermanentFailedTest < ActiveSupport::TestCase
|
||||||
assert_equal('new', ticket.state.name)
|
assert_equal('new', ticket.state.name)
|
||||||
assert_equal(2, ticket.articles.count)
|
assert_equal(2, ticket.articles.count)
|
||||||
|
|
||||||
article = Ticket::Article.create(
|
article = Ticket::Article.create!(
|
||||||
ticket_id: ticket.id,
|
ticket_id: ticket.id,
|
||||||
from: 'some_sender@example.com',
|
from: 'some_sender@example.com',
|
||||||
to: 'some_recipient@example.com',
|
to: 'some_recipient@example.com',
|
||||||
|
|
110
test/unit/email_process_bounce_delivery_temporary_failed_test.rb
Normal file
110
test/unit/email_process_bounce_delivery_temporary_failed_test.rb
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class EmailProcessBounceDeliveryTemporaryFailed < ActiveSupport::TestCase
|
||||||
|
|
||||||
|
test 'process with temp faild bounce email' do
|
||||||
|
|
||||||
|
ticket = Ticket.create!(
|
||||||
|
title: 'temp failed check - ms',
|
||||||
|
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: 'temp failed 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,
|
||||||
|
)
|
||||||
|
travel 1.second
|
||||||
|
|
||||||
|
# temp faild bounce email
|
||||||
|
email_raw_string = "Content-Type: multipart/report; boundary=\"000000000000ca4a1a057417a375\"; report-type=delivery-status
|
||||||
|
From: Mail Delivery Subsystem <mailer-daemon@example.com>
|
||||||
|
To: service@example.de
|
||||||
|
Auto-Submitted: auto-replied
|
||||||
|
Subject: Delivery Status Notification (Delay)
|
||||||
|
References: #{article.message_id}
|
||||||
|
In-Reply-To: #{article.message_id}
|
||||||
|
Message-ID: <5b7e8af4.1c69fb81.3ac1b.e296.GMRIR@mx.example.com>
|
||||||
|
Date: Thu, 23 Aug 2018 03:22:44 -0700 (PDT)
|
||||||
|
|
||||||
|
--000000000000ca4a1a057417a375
|
||||||
|
Content-Type: multipart/related; boundary=\"000000000000ca53d4057417a37c\"
|
||||||
|
|
||||||
|
--000000000000ca53d4057417a37c
|
||||||
|
Content-Type: multipart/alternative; boundary=\"000000000000ca53de057417a37d\"
|
||||||
|
|
||||||
|
--000000000000ca53de057417a37d
|
||||||
|
Content-Type: text/plain; charset=\"UTF-8\"
|
||||||
|
Content-Transfer-Encoding: quoted-printable
|
||||||
|
|
||||||
|
|
||||||
|
** Zustellung nicht abgeschlossen **
|
||||||
|
|
||||||
|
Bei der Zustellung Ihrer Nachricht an bob.smith@example.d=
|
||||||
|
e ist ein vor=C3=BCbergehendes Problem aufgetreten. Gmail versucht noch wei=
|
||||||
|
tere 46=C2=A0Stunden, die Nachricht zuzustellen. Sie werden benachrichtigt,=
|
||||||
|
falls die Zustellung dauerhaft fehlschl=C3=A4gt.
|
||||||
|
|
||||||
|
Hier erfahren Sie mehr: https://support.example.com/mail/answer/7720
|
||||||
|
|
||||||
|
Antwort:
|
||||||
|
|
||||||
|
The recipient server did not accept our requests to connect. Learn more at =
|
||||||
|
https://support.example.com/mail/answer/7720=20
|
||||||
|
[example.de 00:00:00:c00::13: timed out]
|
||||||
|
[example.de 127.0.0.17: timed out]
|
||||||
|
|
||||||
|
--000000000000ca4a1a057417a375
|
||||||
|
Content-Type: message/delivery-status
|
||||||
|
|
||||||
|
Reporting-MTA: dns; example.com
|
||||||
|
Received-From-MTA: dns; service@example.de
|
||||||
|
Arrival-Date: Wed, 22 Aug 2018 02:00:03 -0700 (PDT)
|
||||||
|
X-Original-Message-ID: #{article.message_id}
|
||||||
|
|
||||||
|
Final-Recipient: rfc822; bob.smith@example.de
|
||||||
|
Action: delayed
|
||||||
|
Status: 4.4.1
|
||||||
|
Diagnostic-Code: smtp; The recipient server did not accept our requests to connect. Learn more at https://support.example.com/mail/answer/7720
|
||||||
|
[example.de 00:00:00:c00::13: timed out]
|
||||||
|
[example.de 127.0.0.17: timed out]
|
||||||
|
Last-Attempt-Date: Thu, 23 Aug 2018 03:22:44 -0700 (PDT)
|
||||||
|
Will-Retry-Until: Sat, 25 Aug 2018 02:00:04 -0700 (PDT)
|
||||||
|
|
||||||
|
--000000000000ca4a1a057417a375
|
||||||
|
Content-Type: message/rfc822
|
||||||
|
|
||||||
|
Date: Wed, 22 Aug 2018 11:00:03 +0200
|
||||||
|
From: example Helpdesk <service@example.de>
|
||||||
|
To: bob.smith@example.de
|
||||||
|
Message-ID: #{article.message_id}
|
||||||
|
Subject: Ihre Anfrage () [Ticket#638810]
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
|
||||||
|
ABC
|
||||||
|
|
||||||
|
--000000000000ca4a1a057417a375--
|
||||||
|
"
|
||||||
|
|
||||||
|
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
|
Loading…
Reference in a new issue