2015-09-20 00:16:22 +00:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class EmailProcessAutoResponseTest < ActiveSupport::TestCase
|
|
|
|
|
2018-05-29 15:42:14 +00:00
|
|
|
test 'process auto reply check - 1' do
|
2016-08-23 06:34:15 +00:00
|
|
|
|
|
|
|
roles = Role.where(name: 'Agent')
|
2018-05-29 15:42:14 +00:00
|
|
|
agent1 = User.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
login: 'ticket-auto-responder-agent1@example.com',
|
|
|
|
firstname: 'AutoReponder',
|
|
|
|
lastname: 'Agent1',
|
|
|
|
email: 'ticket-auto-responder-agent1@example.com',
|
|
|
|
password: 'agentpw',
|
|
|
|
active: true,
|
|
|
|
roles: roles,
|
|
|
|
groups: Group.all,
|
2016-08-23 06:34:15 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
|
2018-05-29 15:42:14 +00:00
|
|
|
Trigger.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '002 auto reply',
|
|
|
|
condition: {
|
|
|
|
'ticket.action' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'create',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
2016-08-23 06:34:15 +00:00
|
|
|
'ticket.state_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::State.lookup(name: 'new').id.to_s,
|
2016-08-23 06:34:15 +00:00
|
|
|
}
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2016-08-23 06:34:15 +00:00
|
|
|
'notification.email' => {
|
2018-12-19 17:31:51 +00:00
|
|
|
'body' => 'some text<br>#{ticket.customer.lastname}<br>#{ticket.title}',
|
2016-08-23 06:34:15 +00:00
|
|
|
'recipient' => 'ticket_customer',
|
2018-12-19 17:31:51 +00:00
|
|
|
'subject' => 'Thanks for your inquiry (#{ticket.title})!',
|
2016-08-23 06:34:15 +00:00
|
|
|
},
|
|
|
|
'ticket.priority_id' => {
|
|
|
|
'value' => Ticket::Priority.lookup(name: '3 high').id.to_s,
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
'ticket.tags' => {
|
2016-08-23 06:34:15 +00:00
|
|
|
'operator' => 'add',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'aa, kk, auto-reply',
|
2016-08-23 06:34:15 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2016-08-23 06:34:15 +00:00
|
|
|
)
|
2015-09-20 00:16:22 +00:00
|
|
|
|
|
|
|
email_raw_string = "From: me@example.com
|
|
|
|
To: customer@example.com
|
|
|
|
Subject: some new subject
|
|
|
|
|
|
|
|
Some Text"
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(true, mail[:'x-zammad-send-auto-response'])
|
2016-08-23 06:34:15 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
assert_equal(2, article_p.ticket.articles.count)
|
2015-09-20 00:16:22 +00:00
|
|
|
|
|
|
|
email_raw_string = "From: me@example.com
|
|
|
|
To: customer@example.com
|
|
|
|
Subject: some new subject
|
|
|
|
X-Loop: yes
|
|
|
|
|
|
|
|
Some Text"
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(false, mail[:'x-zammad-send-auto-response'])
|
2016-08-23 06:34:15 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
assert_equal(1, article_p.ticket.articles.count)
|
2015-09-20 00:16:22 +00:00
|
|
|
|
|
|
|
email_raw_string = "From: me@example.com
|
|
|
|
To: customer@example.com
|
|
|
|
Subject: some new subject
|
|
|
|
Precedence: Bulk
|
|
|
|
|
|
|
|
Some Text"
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(false, mail[:'x-zammad-send-auto-response'])
|
2015-09-20 00:16:22 +00:00
|
|
|
|
|
|
|
email_raw_string = "From: me@example.com
|
|
|
|
To: customer@example.com
|
|
|
|
Subject: some new subject
|
|
|
|
Auto-Submitted: auto-generated
|
|
|
|
|
|
|
|
Some Text"
|
2016-08-23 06:34:15 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
assert_equal(1, article_p.ticket.articles.count)
|
2015-09-20 00:16:22 +00:00
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
_ticket_p, _article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(false, mail[:'x-zammad-send-auto-response'])
|
2015-09-20 00:16:22 +00:00
|
|
|
|
|
|
|
email_raw_string = "From: me@example.com
|
|
|
|
To: customer@example.com
|
|
|
|
Subject: some new subject
|
|
|
|
X-Auto-Response-Suppress: All
|
|
|
|
|
|
|
|
|
|
|
|
Some Text"
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(false, mail[:'x-zammad-send-auto-response'])
|
2016-08-23 06:34:15 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
assert_equal(1, article_p.ticket.articles.count)
|
|
|
|
|
2016-11-23 14:28:12 +00:00
|
|
|
fqdn = Setting.get('fqdn')
|
|
|
|
email_raw_string = "From: me@example.com
|
|
|
|
To: customer@example.com
|
|
|
|
Subject: some new subject
|
|
|
|
Message-ID: <1234@#{fqdn}>
|
|
|
|
|
|
|
|
Some Text"
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(false, mail[:'x-zammad-send-auto-response'])
|
2016-11-23 14:28:12 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
assert_equal(1, article_p.ticket.articles.count)
|
|
|
|
|
|
|
|
fqdn = Setting.get('fqdn')
|
|
|
|
email_raw_string = "From: me@example.com
|
|
|
|
To: customer@example.com
|
|
|
|
Subject: some new subject
|
|
|
|
Message-ID: <1234@not_matching.#{fqdn}>
|
|
|
|
|
|
|
|
Some Text"
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(true, mail[:'x-zammad-send-auto-response'])
|
2016-11-23 14:28:12 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
assert_equal(2, article_p.ticket.articles.count)
|
|
|
|
|
2016-08-23 06:34:15 +00:00
|
|
|
email_raw_string = "Return-Path: <XX@XX.XX>
|
|
|
|
X-Original-To: sales@znuny.com
|
|
|
|
Received: from mail-qk0-f170.example.com (mail-qk0-f170.example.com [209.1.1.1])
|
|
|
|
by arber.znuny.com (Postfix) with ESMTPS id C3AED5FE2E
|
|
|
|
for <sales@znuny.com>; Mon, 22 Aug 2016 19:03:15 +0200 (CEST)
|
|
|
|
Received: by mail-qk0-f170.example.com with SMTP id t7so87721720qkh.1
|
|
|
|
for <sales@znuny.com>; Mon, 22 Aug 2016 10:03:15 -0700 (PDT)
|
|
|
|
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
|
|
|
|
d=XX.XX; s=example;
|
|
|
|
h=to:from:date:message-id:subject:mime-version:precedence
|
|
|
|
:auto-submitted:content-transfer-encoding:content-disposition;
|
|
|
|
bh=SL5tTVvGdxsKjLic38irxzlP439P3jixJH0QTG1HJ5I=;
|
|
|
|
b=CIk3PLELgjOCagyiFFbd6rlb8ZRDGYRUrg5Dntxa7e5X+PT4cgL+IE13N9TFkK8ZUJ
|
|
|
|
GohlaPLGiBymIYLTtYMKUpcf22oiX8ZgGiSu1aEMC1Gsa1ZDf+vpy4kd4+7EecRT3IWF
|
|
|
|
4RafQxeaqe67budhQpO1Z6UAel6BdJj0xguKM=
|
|
|
|
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
|
|
|
|
d=1e100.net; s=20130820;
|
|
|
|
h=x-gm-message-state:to:from:date:message-id:subject:mime-version
|
|
|
|
:precedence:auto-submitted:content-transfer-encoding
|
|
|
|
:content-disposition;
|
|
|
|
bh=SL5tTVvGdxsKjLic38irxzlP439P3jixJH0QTG1HJ5I=;
|
|
|
|
b=PYULo3xigc4O/cuNZ79OathQ5HDMFWWIwUxz6CHbpXDQR5k3EPy/skJU1992hVz9Rl
|
|
|
|
xiGwScBCkMqOjlxHjQSWhFJIxNtdvMk4m0bixBZ79IEvRuQa9cEbqjf6efnV58br5ftQ
|
|
|
|
2osHrtQczoSqLE/d61/o102RfQ0avVyX8XNJik0iepg8MiCY7LTOE9hrbnuDDLxgQecH
|
|
|
|
rMEfkR7bafcUj1YEto5Vd7uV11cVZYx8UIQqVAVbfygv8dTSFeOzz3NyM0M41rRexfYH
|
|
|
|
79Yi5i7z/Wk6q2427wkJ3FIR1B7VQVQEmcq/Texbch+gAXPGBNPUHdg2WHt7NXGktrHL
|
|
|
|
d3DA==
|
|
|
|
X-Gm-Message-State: AE9vXwMCTnihGiG/tc7xNNlhFLcEK6DPp7otypJg5e4alD3xGK2R707BP29druIi/mcdNyaHg1vP5lSZ8EvrwvOF8iA0HNFhECGjBTJ40YrSJAR8E89xVwxFv/er+U3vEpqmPmt+hL4QhxK/+D2gKOcHSxku
|
|
|
|
X-Received: by 10.1.1.1 with SMTP id 17mr25015996qkf.279.1471885393931;
|
|
|
|
Mon, 22 Aug 2016 10:03:13 -0700 (PDT)
|
|
|
|
To: sales@znuny.com
|
|
|
|
From: \"XXX\" <XX@XX.XX>
|
|
|
|
Date: Mon, 22 Aug 2016 10:03:13 -0700
|
|
|
|
Message-ID: <CA+kqV8PH1DU+zcSx3M00Hrm_oJedRLjbgAUdoi9p0+sMwYsyUg@mail.gmail.com>
|
|
|
|
Subject: XX PieroXXway - vacation response RE: Callback Request: XX XX [Ticket#1118974]
|
|
|
|
MIME-Version: 1.0
|
|
|
|
Precedence: bulk
|
|
|
|
X-Autoreply: yes
|
|
|
|
Auto-Submitted: auto-replied
|
|
|
|
Content-Type: text/html; charset=UTF-8
|
|
|
|
Content-Transfer-Encoding: quoted-printable
|
|
|
|
Content-Disposition: inline
|
|
|
|
|
|
|
|
test"
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(false, mail[:'x-zammad-send-auto-response'])
|
2016-08-23 06:34:15 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
assert_equal(1, article_p.ticket.articles.count)
|
|
|
|
|
|
|
|
# add an agent notification
|
2018-05-29 15:42:14 +00:00
|
|
|
Trigger.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '001 additional agent notification',
|
|
|
|
condition: {
|
2016-08-23 06:34:15 +00:00
|
|
|
'ticket.state_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::State.lookup(name: 'new').id.to_s,
|
2016-08-23 06:34:15 +00:00
|
|
|
}
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2016-08-23 06:34:15 +00:00
|
|
|
'notification.email' => {
|
2018-12-19 17:31:51 +00:00
|
|
|
'body' => 'some text<br>#{ticket.customer.lastname}<br>#{ticket.title}',
|
2016-08-23 06:34:15 +00:00
|
|
|
'recipient' => 'ticket_agents',
|
2018-12-19 17:31:51 +00:00
|
|
|
'subject' => 'New Ticket add. info (#{ticket.title})!',
|
2016-08-23 06:34:15 +00:00
|
|
|
},
|
|
|
|
'ticket.priority_id' => {
|
|
|
|
'value' => Ticket::Priority.lookup(name: '3 high').id.to_s,
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
'ticket.tags' => {
|
2016-08-23 06:34:15 +00:00
|
|
|
'operator' => 'add',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'aa, kk, agent-notification',
|
2016-08-23 06:34:15 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2016-08-23 06:34:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
email_raw_string = "From: me@example.com
|
|
|
|
To: customer@example.com
|
|
|
|
Subject: some new subject
|
|
|
|
X-Loop: yes
|
|
|
|
|
|
|
|
Some Text"
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(false, mail[:'x-zammad-send-auto-response'])
|
2016-08-23 06:34:15 +00:00
|
|
|
Scheduler.worker(true)
|
2018-05-29 15:42:14 +00:00
|
|
|
|
|
|
|
tags = ticket_p.tag_list
|
|
|
|
assert_equal('new', ticket_p.state.name)
|
|
|
|
assert_equal('3 high', ticket_p.priority.name)
|
|
|
|
assert(tags.include?('aa'))
|
|
|
|
assert(tags.include?('kk'))
|
|
|
|
assert(tags.include?('agent-notification'))
|
|
|
|
assert_equal(3, tags.count)
|
2016-08-23 06:34:15 +00:00
|
|
|
assert_equal(2, article_p.ticket.articles.count)
|
|
|
|
article_customer = article_p.ticket.articles.first
|
|
|
|
assert_equal('me@example.com', article_customer.from)
|
|
|
|
assert_equal('customer@example.com', article_customer.to)
|
|
|
|
assert_equal('Customer', article_customer.sender.name)
|
|
|
|
assert_equal('email', article_customer.type.name)
|
2018-05-29 15:42:14 +00:00
|
|
|
article_notification = article_p.ticket.articles[1]
|
2016-08-23 06:34:15 +00:00
|
|
|
assert_match(/New Ticket add. info/, article_notification.subject)
|
|
|
|
assert_no_match(/me@example.com/, article_notification.to)
|
|
|
|
assert_match(/#{agent1.email}/, article_notification.to)
|
|
|
|
assert_equal('System', article_notification.sender.name)
|
|
|
|
assert_equal('email', article_notification.type.name)
|
|
|
|
|
2018-05-29 15:42:14 +00:00
|
|
|
Setting.set('ticket_trigger_recursive', true)
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(false, mail[:'x-zammad-send-auto-response'])
|
2018-05-29 15:42:14 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
|
|
|
|
tags = ticket_p.tag_list
|
|
|
|
assert_equal('new', ticket_p.state.name)
|
|
|
|
assert_equal('3 high', ticket_p.priority.name)
|
|
|
|
assert(tags.include?('aa'))
|
|
|
|
assert(tags.include?('kk'))
|
|
|
|
assert(tags.include?('agent-notification'))
|
|
|
|
assert_equal(3, tags.count)
|
|
|
|
assert_equal(2, article_p.ticket.articles.count)
|
|
|
|
article_customer = article_p.ticket.articles.first
|
|
|
|
assert_equal('me@example.com', article_customer.from)
|
|
|
|
assert_equal('customer@example.com', article_customer.to)
|
|
|
|
assert_equal('Customer', article_customer.sender.name)
|
|
|
|
assert_equal('email', article_customer.type.name)
|
|
|
|
article_notification = article_p.ticket.articles[1]
|
|
|
|
assert_match(/New Ticket add. info/, article_notification.subject)
|
|
|
|
assert_no_match(/me@example.com/, article_notification.to)
|
|
|
|
assert_match(/#{agent1.email}/, article_notification.to)
|
|
|
|
assert_equal('System', article_notification.sender.name)
|
|
|
|
assert_equal('email', article_notification.type.name)
|
|
|
|
|
|
|
|
Setting.set('ticket_trigger_recursive', false)
|
|
|
|
|
|
|
|
email_raw_string = "From: me@example.com
|
|
|
|
To: customer@example.com
|
|
|
|
Subject: some new subject
|
|
|
|
|
|
|
|
Some Text"
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(true, mail[:'x-zammad-send-auto-response'])
|
2018-05-29 15:42:14 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
|
|
|
|
tags = ticket_p.tag_list
|
|
|
|
assert_equal('new', ticket_p.state.name)
|
|
|
|
assert_equal('3 high', ticket_p.priority.name)
|
|
|
|
assert(tags.include?('aa'))
|
|
|
|
assert(tags.include?('kk'))
|
|
|
|
assert(tags.include?('agent-notification'))
|
|
|
|
assert(tags.include?('auto-reply'))
|
|
|
|
assert_equal(3, article_p.ticket.articles.count)
|
|
|
|
article_customer = article_p.ticket.articles[0]
|
|
|
|
assert_equal('me@example.com', article_customer.from)
|
|
|
|
assert_equal('customer@example.com', article_customer.to)
|
|
|
|
assert_equal('Customer', article_customer.sender.name)
|
|
|
|
assert_equal('email', article_customer.type.name)
|
|
|
|
article_notification = article_p.ticket.articles[1]
|
|
|
|
assert_match(/New Ticket add. info/, article_notification.subject)
|
|
|
|
assert_no_match(/me@example.com/, article_notification.to)
|
|
|
|
assert_match(/#{agent1.email}/, article_notification.to)
|
|
|
|
assert_equal('System', article_notification.sender.name)
|
|
|
|
assert_equal('email', article_notification.type.name)
|
|
|
|
article_auto_reply = article_p.ticket.articles[2]
|
|
|
|
assert_match(/Thanks for your inquiry/, article_auto_reply.subject)
|
|
|
|
assert_match(/me@example.com/, article_auto_reply.to)
|
|
|
|
assert_equal('System', article_auto_reply.sender.name)
|
|
|
|
assert_equal('email', article_auto_reply.type.name)
|
|
|
|
|
|
|
|
Setting.set('ticket_trigger_recursive', true)
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(true, mail[:'x-zammad-send-auto-response'])
|
2018-05-29 15:42:14 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
tags = ticket_p.tag_list
|
|
|
|
assert_equal('new', ticket_p.state.name)
|
|
|
|
assert_equal('3 high', ticket_p.priority.name)
|
|
|
|
assert(tags.include?('aa'))
|
|
|
|
assert(tags.include?('kk'))
|
|
|
|
assert(tags.include?('agent-notification'))
|
|
|
|
assert(tags.include?('auto-reply'))
|
|
|
|
assert_equal(3, article_p.ticket.articles.count)
|
|
|
|
article_customer = article_p.ticket.articles[0]
|
|
|
|
assert_equal('me@example.com', article_customer.from)
|
|
|
|
assert_equal('customer@example.com', article_customer.to)
|
|
|
|
assert_equal('Customer', article_customer.sender.name)
|
|
|
|
assert_equal('email', article_customer.type.name)
|
|
|
|
article_notification = article_p.ticket.articles[1]
|
|
|
|
assert_match(/New Ticket add. info/, article_notification.subject)
|
|
|
|
assert_no_match(/me@example.com/, article_notification.to)
|
|
|
|
assert_match(/#{agent1.email}/, article_notification.to)
|
|
|
|
assert_equal('System', article_notification.sender.name)
|
|
|
|
assert_equal('email', article_notification.type.name)
|
|
|
|
article_auto_reply = article_p.ticket.articles[2]
|
|
|
|
assert_match(/Thanks for your inquiry/, article_auto_reply.subject)
|
|
|
|
assert_match(/me@example.com/, article_auto_reply.to)
|
|
|
|
assert_equal('System', article_auto_reply.sender.name)
|
|
|
|
assert_equal('email', article_auto_reply.type.name)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'process auto reply check - 2' do
|
|
|
|
|
|
|
|
roles = Role.where(name: 'Agent')
|
|
|
|
agent1 = User.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
login: 'ticket-auto-responder-agent1@example.com',
|
|
|
|
firstname: 'AutoReponder',
|
|
|
|
lastname: 'Agent1',
|
|
|
|
email: 'ticket-auto-responder-agent1@example.com',
|
|
|
|
password: 'agentpw',
|
|
|
|
active: true,
|
|
|
|
roles: roles,
|
|
|
|
groups: Group.all,
|
2018-05-29 15:42:14 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
|
|
|
|
Trigger.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '001 auto reply',
|
|
|
|
condition: {
|
|
|
|
'ticket.action' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'create',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
'ticket.state_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::State.lookup(name: 'new').id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
}
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'notification.email' => {
|
2018-12-19 17:31:51 +00:00
|
|
|
'body' => 'some text<br>#{ticket.customer.lastname}<br>#{ticket.title}',
|
2018-05-29 15:42:14 +00:00
|
|
|
'recipient' => 'ticket_customer',
|
2018-12-19 17:31:51 +00:00
|
|
|
'subject' => 'Thanks for your inquiry (#{ticket.title})!',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
'ticket.priority_id' => {
|
|
|
|
'value' => Ticket::Priority.lookup(name: '3 high').id.to_s,
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
'ticket.tags' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'operator' => 'add',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'aa, kk, auto-reply',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2018-05-29 15:42:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
email_raw_string = "From: me@example.com
|
|
|
|
To: customer@example.com
|
|
|
|
Subject: some new subject
|
|
|
|
|
|
|
|
Some Text"
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(true, mail[:'x-zammad-send-auto-response'])
|
2018-05-29 15:42:14 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
assert_equal(2, article_p.ticket.articles.count)
|
|
|
|
|
|
|
|
email_raw_string = "From: me@example.com
|
|
|
|
To: customer@example.com
|
|
|
|
Subject: some new subject
|
|
|
|
X-Loop: yes
|
|
|
|
|
|
|
|
Some Text"
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(false, mail[:'x-zammad-send-auto-response'])
|
2018-05-29 15:42:14 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
assert_equal(1, article_p.ticket.articles.count)
|
|
|
|
|
|
|
|
email_raw_string = "From: me@example.com
|
|
|
|
To: customer@example.com
|
|
|
|
Subject: some new subject
|
|
|
|
Precedence: Bulk
|
|
|
|
|
|
|
|
Some Text"
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(false, mail[:'x-zammad-send-auto-response'])
|
2018-05-29 15:42:14 +00:00
|
|
|
|
|
|
|
email_raw_string = "From: me@example.com
|
|
|
|
To: customer@example.com
|
|
|
|
Subject: some new subject
|
|
|
|
Auto-Submitted: auto-generated
|
|
|
|
|
|
|
|
Some Text"
|
|
|
|
Scheduler.worker(true)
|
|
|
|
assert_equal(1, article_p.ticket.articles.count)
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
_ticket_p, _article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(false, mail[:'x-zammad-send-auto-response'])
|
2018-05-29 15:42:14 +00:00
|
|
|
|
|
|
|
email_raw_string = "From: me@example.com
|
|
|
|
To: customer@example.com
|
|
|
|
Subject: some new subject
|
|
|
|
X-Auto-Response-Suppress: All
|
|
|
|
|
|
|
|
|
|
|
|
Some Text"
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(false, mail[:'x-zammad-send-auto-response'])
|
2018-05-29 15:42:14 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
assert_equal(1, article_p.ticket.articles.count)
|
|
|
|
|
|
|
|
fqdn = Setting.get('fqdn')
|
|
|
|
email_raw_string = "From: me@example.com
|
|
|
|
To: customer@example.com
|
|
|
|
Subject: some new subject
|
|
|
|
Message-ID: <1234@#{fqdn}>
|
|
|
|
|
|
|
|
Some Text"
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(false, mail[:'x-zammad-send-auto-response'])
|
2018-05-29 15:42:14 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
assert_equal(1, article_p.ticket.articles.count)
|
|
|
|
|
|
|
|
fqdn = Setting.get('fqdn')
|
|
|
|
email_raw_string = "From: me@example.com
|
|
|
|
To: customer@example.com
|
|
|
|
Subject: some new subject
|
|
|
|
Message-ID: <1234@not_matching.#{fqdn}>
|
|
|
|
|
|
|
|
Some Text"
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(true, mail[:'x-zammad-send-auto-response'])
|
2018-05-29 15:42:14 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
assert_equal(2, article_p.ticket.articles.count)
|
|
|
|
|
|
|
|
email_raw_string = "Return-Path: <XX@XX.XX>
|
|
|
|
X-Original-To: sales@znuny.com
|
|
|
|
Received: from mail-qk0-f170.example.com (mail-qk0-f170.example.com [209.1.1.1])
|
|
|
|
by arber.znuny.com (Postfix) with ESMTPS id C3AED5FE2E
|
|
|
|
for <sales@znuny.com>; Mon, 22 Aug 2016 19:03:15 +0200 (CEST)
|
|
|
|
Received: by mail-qk0-f170.example.com with SMTP id t7so87721720qkh.1
|
|
|
|
for <sales@znuny.com>; Mon, 22 Aug 2016 10:03:15 -0700 (PDT)
|
|
|
|
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
|
|
|
|
d=XX.XX; s=example;
|
|
|
|
h=to:from:date:message-id:subject:mime-version:precedence
|
|
|
|
:auto-submitted:content-transfer-encoding:content-disposition;
|
|
|
|
bh=SL5tTVvGdxsKjLic38irxzlP439P3jixJH0QTG1HJ5I=;
|
|
|
|
b=CIk3PLELgjOCagyiFFbd6rlb8ZRDGYRUrg5Dntxa7e5X+PT4cgL+IE13N9TFkK8ZUJ
|
|
|
|
GohlaPLGiBymIYLTtYMKUpcf22oiX8ZgGiSu1aEMC1Gsa1ZDf+vpy4kd4+7EecRT3IWF
|
|
|
|
4RafQxeaqe67budhQpO1Z6UAel6BdJj0xguKM=
|
|
|
|
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
|
|
|
|
d=1e100.net; s=20130820;
|
|
|
|
h=x-gm-message-state:to:from:date:message-id:subject:mime-version
|
|
|
|
:precedence:auto-submitted:content-transfer-encoding
|
|
|
|
:content-disposition;
|
|
|
|
bh=SL5tTVvGdxsKjLic38irxzlP439P3jixJH0QTG1HJ5I=;
|
|
|
|
b=PYULo3xigc4O/cuNZ79OathQ5HDMFWWIwUxz6CHbpXDQR5k3EPy/skJU1992hVz9Rl
|
|
|
|
xiGwScBCkMqOjlxHjQSWhFJIxNtdvMk4m0bixBZ79IEvRuQa9cEbqjf6efnV58br5ftQ
|
|
|
|
2osHrtQczoSqLE/d61/o102RfQ0avVyX8XNJik0iepg8MiCY7LTOE9hrbnuDDLxgQecH
|
|
|
|
rMEfkR7bafcUj1YEto5Vd7uV11cVZYx8UIQqVAVbfygv8dTSFeOzz3NyM0M41rRexfYH
|
|
|
|
79Yi5i7z/Wk6q2427wkJ3FIR1B7VQVQEmcq/Texbch+gAXPGBNPUHdg2WHt7NXGktrHL
|
|
|
|
d3DA==
|
|
|
|
X-Gm-Message-State: AE9vXwMCTnihGiG/tc7xNNlhFLcEK6DPp7otypJg5e4alD3xGK2R707BP29druIi/mcdNyaHg1vP5lSZ8EvrwvOF8iA0HNFhECGjBTJ40YrSJAR8E89xVwxFv/er+U3vEpqmPmt+hL4QhxK/+D2gKOcHSxku
|
|
|
|
X-Received: by 10.1.1.1 with SMTP id 17mr25015996qkf.279.1471885393931;
|
|
|
|
Mon, 22 Aug 2016 10:03:13 -0700 (PDT)
|
|
|
|
To: sales@znuny.com
|
|
|
|
From: \"XXX\" <XX@XX.XX>
|
|
|
|
Date: Mon, 22 Aug 2016 10:03:13 -0700
|
|
|
|
Message-ID: <CA+kqV8PH1DU+zcSx3M00Hrm_oJedRLjbgAUdoi9p0+sMwYsyUg@mail.gmail.com>
|
|
|
|
Subject: XX PieroXXway - vacation response RE: Callback Request: XX XX [Ticket#1118974]
|
|
|
|
MIME-Version: 1.0
|
|
|
|
Precedence: bulk
|
|
|
|
X-Autoreply: yes
|
|
|
|
Auto-Submitted: auto-replied
|
|
|
|
Content-Type: text/html; charset=UTF-8
|
|
|
|
Content-Transfer-Encoding: quoted-printable
|
|
|
|
Content-Disposition: inline
|
|
|
|
|
|
|
|
test"
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(false, mail[:'x-zammad-send-auto-response'])
|
2018-05-29 15:42:14 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
assert_equal(1, article_p.ticket.articles.count)
|
|
|
|
|
|
|
|
# add an agent notification
|
|
|
|
Trigger.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '002 additional agent notification',
|
|
|
|
condition: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.state_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::State.lookup(name: 'new').id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
}
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'notification.email' => {
|
2018-12-19 17:31:51 +00:00
|
|
|
'body' => 'some text<br>#{ticket.customer.lastname}<br>#{ticket.title}',
|
2018-05-29 15:42:14 +00:00
|
|
|
'recipient' => 'ticket_agents',
|
2018-12-19 17:31:51 +00:00
|
|
|
'subject' => 'New Ticket add. info (#{ticket.title})!',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
'ticket.priority_id' => {
|
|
|
|
'value' => Ticket::Priority.lookup(name: '3 high').id.to_s,
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
'ticket.tags' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'operator' => 'add',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'aa, kk, agent-notification',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2018-05-29 15:42:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
email_raw_string = "From: me@example.com
|
|
|
|
To: customer@example.com
|
|
|
|
Subject: some new subject
|
|
|
|
X-Loop: yes
|
|
|
|
|
|
|
|
Some Text"
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(false, mail[:'x-zammad-send-auto-response'])
|
2018-05-29 15:42:14 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
|
|
|
|
tags = ticket_p.tag_list
|
|
|
|
assert_equal('new', ticket_p.state.name)
|
|
|
|
assert_equal('3 high', ticket_p.priority.name)
|
|
|
|
assert(tags.include?('aa'))
|
|
|
|
assert(tags.include?('kk'))
|
|
|
|
assert(tags.include?('agent-notification'))
|
|
|
|
assert_equal(3, tags.count)
|
|
|
|
assert_equal(2, article_p.ticket.articles.count)
|
|
|
|
article_customer = article_p.ticket.articles.first
|
|
|
|
assert_equal('me@example.com', article_customer.from)
|
|
|
|
assert_equal('customer@example.com', article_customer.to)
|
|
|
|
assert_equal('Customer', article_customer.sender.name)
|
|
|
|
assert_equal('email', article_customer.type.name)
|
|
|
|
article_notification = article_p.ticket.articles[1]
|
|
|
|
assert_match(/New Ticket add. info/, article_notification.subject)
|
|
|
|
assert_no_match(/me@example.com/, article_notification.to)
|
|
|
|
assert_match(/#{agent1.email}/, article_notification.to)
|
|
|
|
assert_equal('System', article_notification.sender.name)
|
|
|
|
assert_equal('email', article_notification.type.name)
|
|
|
|
|
|
|
|
Setting.set('ticket_trigger_recursive', true)
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(false, mail[:'x-zammad-send-auto-response'])
|
2018-05-29 15:42:14 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
|
|
|
|
tags = ticket_p.tag_list
|
|
|
|
assert_equal('new', ticket_p.state.name)
|
|
|
|
assert_equal('3 high', ticket_p.priority.name)
|
|
|
|
assert(tags.include?('aa'))
|
|
|
|
assert(tags.include?('kk'))
|
|
|
|
assert(tags.include?('agent-notification'))
|
|
|
|
assert_equal(3, tags.count)
|
|
|
|
assert_equal(2, article_p.ticket.articles.count)
|
|
|
|
article_customer = article_p.ticket.articles.first
|
|
|
|
assert_equal('me@example.com', article_customer.from)
|
|
|
|
assert_equal('customer@example.com', article_customer.to)
|
|
|
|
assert_equal('Customer', article_customer.sender.name)
|
|
|
|
assert_equal('email', article_customer.type.name)
|
|
|
|
article_notification = article_p.ticket.articles[1]
|
|
|
|
assert_match(/New Ticket add. info/, article_notification.subject)
|
|
|
|
assert_no_match(/me@example.com/, article_notification.to)
|
|
|
|
assert_match(/#{agent1.email}/, article_notification.to)
|
|
|
|
assert_equal('System', article_notification.sender.name)
|
|
|
|
assert_equal('email', article_notification.type.name)
|
|
|
|
|
|
|
|
Setting.set('ticket_trigger_recursive', false)
|
|
|
|
|
|
|
|
email_raw_string = "From: me@example.com
|
|
|
|
To: customer@example.com
|
|
|
|
Subject: some new subject
|
|
|
|
|
|
|
|
Some Text"
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(true, mail[:'x-zammad-send-auto-response'])
|
2018-05-29 15:42:14 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
|
|
|
|
tags = ticket_p.tag_list
|
|
|
|
assert_equal('new', ticket_p.state.name)
|
|
|
|
assert_equal('3 high', ticket_p.priority.name)
|
|
|
|
assert(tags.include?('aa'))
|
|
|
|
assert(tags.include?('kk'))
|
|
|
|
assert(tags.include?('agent-notification'))
|
|
|
|
assert(tags.include?('auto-reply'))
|
|
|
|
assert_equal(3, article_p.ticket.articles.count)
|
|
|
|
article_customer = article_p.ticket.articles[0]
|
|
|
|
assert_equal('me@example.com', article_customer.from)
|
|
|
|
assert_equal('customer@example.com', article_customer.to)
|
|
|
|
assert_equal('Customer', article_customer.sender.name)
|
|
|
|
assert_equal('email', article_customer.type.name)
|
|
|
|
article_auto_reply = article_p.ticket.articles[1]
|
|
|
|
assert_match(/Thanks for your inquiry/, article_auto_reply.subject)
|
|
|
|
assert_match(/me@example.com/, article_auto_reply.to)
|
|
|
|
assert_equal('System', article_auto_reply.sender.name)
|
|
|
|
assert_equal('email', article_auto_reply.type.name)
|
|
|
|
article_notification = article_p.ticket.articles[2]
|
|
|
|
assert_match(/New Ticket add. info/, article_notification.subject)
|
|
|
|
assert_no_match(/me@example.com/, article_notification.to)
|
|
|
|
assert_match(/#{agent1.email}/, article_notification.to)
|
|
|
|
assert_equal('System', article_notification.sender.name)
|
|
|
|
assert_equal('email', article_notification.type.name)
|
|
|
|
|
|
|
|
Setting.set('ticket_trigger_recursive', true)
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(true, mail[:'x-zammad-send-auto-response'])
|
2018-05-29 15:42:14 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
tags = ticket_p.tag_list
|
|
|
|
assert_equal('new', ticket_p.state.name)
|
|
|
|
assert_equal('3 high', ticket_p.priority.name)
|
|
|
|
assert(tags.include?('aa'))
|
|
|
|
assert(tags.include?('kk'))
|
|
|
|
assert(tags.include?('agent-notification'))
|
|
|
|
assert(tags.include?('auto-reply'))
|
|
|
|
assert_equal(3, article_p.ticket.articles.count)
|
|
|
|
article_customer = article_p.ticket.articles[0]
|
|
|
|
assert_equal('me@example.com', article_customer.from)
|
|
|
|
assert_equal('customer@example.com', article_customer.to)
|
|
|
|
assert_equal('Customer', article_customer.sender.name)
|
|
|
|
assert_equal('email', article_customer.type.name)
|
|
|
|
article_auto_reply = article_p.ticket.articles[1]
|
|
|
|
assert_match(/Thanks for your inquiry/, article_auto_reply.subject)
|
|
|
|
assert_match(/me@example.com/, article_auto_reply.to)
|
|
|
|
assert_equal('System', article_auto_reply.sender.name)
|
|
|
|
assert_equal('email', article_auto_reply.type.name)
|
|
|
|
article_notification = article_p.ticket.articles[2]
|
|
|
|
assert_match(/New Ticket add. info/, article_notification.subject)
|
|
|
|
assert_no_match(/me@example.com/, article_notification.to)
|
|
|
|
assert_match(/#{agent1.email}/, article_notification.to)
|
|
|
|
assert_equal('System', article_notification.sender.name)
|
|
|
|
assert_equal('email', article_notification.type.name)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'process auto reply check - recursive' do
|
|
|
|
|
|
|
|
roles = Role.where(name: 'Agent')
|
|
|
|
agent1 = User.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
login: 'ticket-auto-responder-agent1@example.com',
|
|
|
|
firstname: 'AutoReponder',
|
|
|
|
lastname: 'Agent1',
|
|
|
|
email: 'ticket-auto-responder-agent1@example.com',
|
|
|
|
password: 'agentpw',
|
|
|
|
active: true,
|
|
|
|
roles: roles,
|
|
|
|
groups: Group.all,
|
2018-05-29 15:42:14 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
|
|
|
|
Trigger.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '001 auto reply',
|
|
|
|
condition: {
|
|
|
|
'ticket.action' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'create',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
'ticket.state_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::State.lookup(name: 'open').id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
}
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'notification.email' => {
|
2018-12-19 17:31:51 +00:00
|
|
|
'body' => 'some text<br>#{ticket.customer.lastname}<br>#{ticket.title}',
|
2018-05-29 15:42:14 +00:00
|
|
|
'recipient' => 'ticket_customer',
|
2018-12-19 17:31:51 +00:00
|
|
|
'subject' => 'Thanks for your inquiry (#{ticket.title})!',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
'ticket.priority_id' => {
|
|
|
|
'value' => Ticket::Priority.lookup(name: '3 high').id.to_s,
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
'ticket.tags' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'operator' => 'add',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'aa, kk, auto-reply',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2018-05-29 15:42:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# add an agent notification
|
|
|
|
Trigger.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '002 additional agent notification',
|
|
|
|
condition: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.state_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::State.lookup(name: 'new').id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
}
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'notification.email' => {
|
2018-12-19 17:31:51 +00:00
|
|
|
'body' => 'some text<br>#{ticket.customer.lastname}<br>#{ticket.title}',
|
2018-05-29 15:42:14 +00:00
|
|
|
'recipient' => 'ticket_agents',
|
2018-12-19 17:31:51 +00:00
|
|
|
'subject' => 'New Ticket add. info (#{ticket.title})!',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
'ticket.priority_id' => {
|
|
|
|
'value' => Ticket::Priority.lookup(name: '3 high').id.to_s,
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
'ticket.state_id' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'value' => Ticket::State.lookup(name: 'open').id.to_s,
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
'ticket.tags' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'operator' => 'add',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'aa, kk, agent-notification',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2018-05-29 15:42:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
email_raw_string = "From: me@example.com
|
|
|
|
To: customer@example.com
|
|
|
|
Subject: some new subject
|
|
|
|
X-Loop: yes
|
|
|
|
|
|
|
|
Some Text"
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(false, mail[:'x-zammad-send-auto-response'])
|
2018-05-29 15:42:14 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
|
|
|
|
tags = ticket_p.tag_list
|
|
|
|
assert_equal('open', ticket_p.state.name)
|
|
|
|
assert_equal('3 high', ticket_p.priority.name)
|
|
|
|
assert(tags.include?('aa'))
|
|
|
|
assert(tags.include?('kk'))
|
|
|
|
assert(tags.include?('agent-notification'))
|
|
|
|
assert_equal(3, tags.count)
|
|
|
|
assert_equal(2, article_p.ticket.articles.count)
|
|
|
|
article_customer = article_p.ticket.articles.first
|
|
|
|
assert_equal('me@example.com', article_customer.from)
|
|
|
|
assert_equal('customer@example.com', article_customer.to)
|
|
|
|
assert_equal('Customer', article_customer.sender.name)
|
|
|
|
assert_equal('email', article_customer.type.name)
|
|
|
|
article_notification = article_p.ticket.articles[1]
|
|
|
|
assert_match(/New Ticket add. info/, article_notification.subject)
|
|
|
|
assert_no_match(/me@example.com/, article_notification.to)
|
|
|
|
assert_match(/#{agent1.email}/, article_notification.to)
|
|
|
|
assert_equal('System', article_notification.sender.name)
|
|
|
|
assert_equal('email', article_notification.type.name)
|
|
|
|
|
|
|
|
Setting.set('ticket_trigger_recursive', true)
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(false, mail[:'x-zammad-send-auto-response'])
|
2018-05-29 15:42:14 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
|
|
|
|
tags = ticket_p.tag_list
|
|
|
|
assert_equal('open', ticket_p.state.name)
|
|
|
|
assert_equal('3 high', ticket_p.priority.name)
|
|
|
|
assert(tags.include?('aa'))
|
|
|
|
assert(tags.include?('kk'))
|
|
|
|
assert(tags.include?('agent-notification'))
|
|
|
|
assert_equal(3, tags.count)
|
|
|
|
assert_equal(2, article_p.ticket.articles.count)
|
|
|
|
article_customer = article_p.ticket.articles.first
|
|
|
|
assert_equal('me@example.com', article_customer.from)
|
|
|
|
assert_equal('customer@example.com', article_customer.to)
|
|
|
|
assert_equal('Customer', article_customer.sender.name)
|
|
|
|
assert_equal('email', article_customer.type.name)
|
|
|
|
article_notification = article_p.ticket.articles[1]
|
|
|
|
assert_match(/New Ticket add. info/, article_notification.subject)
|
|
|
|
assert_no_match(/me@example.com/, article_notification.to)
|
|
|
|
assert_match(/#{agent1.email}/, article_notification.to)
|
|
|
|
assert_equal('System', article_notification.sender.name)
|
|
|
|
assert_equal('email', article_notification.type.name)
|
|
|
|
|
|
|
|
Setting.set('ticket_trigger_recursive', false)
|
|
|
|
|
|
|
|
email_raw_string = "From: me@example.com
|
|
|
|
To: customer@example.com
|
|
|
|
Subject: some new subject
|
|
|
|
|
|
|
|
Some Text"
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(true, mail[:'x-zammad-send-auto-response'])
|
2018-05-29 15:42:14 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
|
|
|
|
tags = ticket_p.tag_list
|
|
|
|
assert_equal('open', ticket_p.state.name)
|
|
|
|
assert_equal('3 high', ticket_p.priority.name)
|
|
|
|
assert(tags.include?('aa'))
|
|
|
|
assert(tags.include?('kk'))
|
|
|
|
assert(tags.include?('agent-notification'))
|
|
|
|
assert_equal(2, article_p.ticket.articles.count)
|
|
|
|
article_customer = article_p.ticket.articles[0]
|
|
|
|
assert_equal('me@example.com', article_customer.from)
|
|
|
|
assert_equal('customer@example.com', article_customer.to)
|
|
|
|
assert_equal('Customer', article_customer.sender.name)
|
|
|
|
assert_equal('email', article_customer.type.name)
|
|
|
|
article_notification = article_p.ticket.articles[1]
|
|
|
|
assert_match(/New Ticket add. info/, article_notification.subject)
|
|
|
|
assert_no_match(/me@example.com/, article_notification.to)
|
|
|
|
assert_match(/#{agent1.email}/, article_notification.to)
|
|
|
|
assert_equal('System', article_notification.sender.name)
|
|
|
|
assert_equal('email', article_notification.type.name)
|
|
|
|
|
|
|
|
Setting.set('ticket_trigger_recursive', true)
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2020-08-21 08:18:31 +00:00
|
|
|
assert_equal(true, mail[:'x-zammad-send-auto-response'])
|
2018-05-29 15:42:14 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
tags = ticket_p.tag_list
|
|
|
|
assert_equal('open', ticket_p.state.name)
|
|
|
|
assert_equal('3 high', ticket_p.priority.name)
|
|
|
|
assert(tags.include?('aa'))
|
|
|
|
assert(tags.include?('kk'))
|
|
|
|
assert(tags.include?('agent-notification'))
|
|
|
|
assert(tags.include?('auto-reply'))
|
|
|
|
assert_equal(3, article_p.ticket.articles.count)
|
|
|
|
article_customer = article_p.ticket.articles[0]
|
|
|
|
assert_equal('me@example.com', article_customer.from)
|
|
|
|
assert_equal('customer@example.com', article_customer.to)
|
|
|
|
assert_equal('Customer', article_customer.sender.name)
|
|
|
|
assert_equal('email', article_customer.type.name)
|
|
|
|
article_notification = article_p.ticket.articles[1]
|
|
|
|
assert_match(/New Ticket add. info/, article_notification.subject)
|
|
|
|
assert_no_match(/me@example.com/, article_notification.to)
|
|
|
|
assert_match(/#{agent1.email}/, article_notification.to)
|
|
|
|
assert_equal('System', article_notification.sender.name)
|
|
|
|
assert_equal('email', article_notification.type.name)
|
|
|
|
article_auto_reply = article_p.ticket.articles[2]
|
|
|
|
assert_match(/Thanks for your inquiry/, article_auto_reply.subject)
|
|
|
|
assert_match(/me@example.com/, article_auto_reply.to)
|
|
|
|
assert_equal('System', article_auto_reply.sender.name)
|
|
|
|
assert_equal('email', article_auto_reply.type.name)
|
2015-09-20 00:16:22 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|