From 397983094e9ac8a5dca2a63088c6f80f977e4718 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 3 May 2016 15:54:21 +0200 Subject: [PATCH] Improved trigger. --- db/migrate/20160503000001_update_trigger.rb | 84 +++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 db/migrate/20160503000001_update_trigger.rb diff --git a/db/migrate/20160503000001_update_trigger.rb b/db/migrate/20160503000001_update_trigger.rb new file mode 100644 index 000000000..703777a53 --- /dev/null +++ b/db/migrate/20160503000001_update_trigger.rb @@ -0,0 +1,84 @@ +class UpdateTrigger < ActiveRecord::Migration + def up + + # return if it's a new setup + return if !Setting.find_by(name: 'system_init_done') + + Trigger.create_or_update( + name: 'auto reply (on new tickets)', + condition: { + 'ticket.action' => { + 'operator' => 'is', + 'value' => 'create', + }, + 'ticket.state_id' => { + 'operator' => 'is not', + 'value' => '4', + }, + 'article.type_id' => { + 'operator' => 'is', + 'value' => [ + Ticket::Article::Type.lookup(name: 'email').id, + Ticket::Article::Type.lookup(name: 'phone').id, + Ticket::Article::Type.lookup(name: 'web').id, + ], + }, + }, + perform: { + 'notification.email' => { + 'body' => '

Your request (#{config.ticket_hook}##{ticket.number}) has been received and will be reviewed by our support staff.

+
+

To provide additional information, please reply to this email or click on the following link: + #{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id} +

+
+

Zammad, your customer support system

', + 'recipient' => 'ticket_customer', + 'subject' => 'Thanks for your inquiry (#{ticket.title})', + }, + }, + active: false, + created_by_id: 1, + updated_by_id: 1, + ) + Trigger.create_or_update( + name: 'auto reply (on follow up of tickets)', + condition: { + 'ticket.action' => { + 'operator' => 'is', + 'value' => 'update', + }, + 'article.sender_id' => { + 'operator' => 'is', + 'value' => Ticket::Article::Sender.lookup(name: 'Customer').id, + }, + 'article.type_id' => { + 'operator' => 'is', + 'value' => [ + Ticket::Article::Type.lookup(name: 'email').id, + Ticket::Article::Type.lookup(name: 'phone').id, + Ticket::Article::Type.lookup(name: 'web').id, + ], + }, + }, + perform: { + 'notification.email' => { + 'body' => '

Your follow up for (#{config.ticket_hook}##{ticket.number}) has been received and will be reviewed by our support staff.

+
+

To provide additional information, please reply to this email or click on the following link: + #{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id} +

+
+

Zammad, your customer support system

', + 'recipient' => 'ticket_customer', + 'subject' => 'Thanks for your follow up (#{ticket.title})', + }, + }, + active: false, + created_by_id: 1, + updated_by_id: 1, + ) + + end + +end