20160503000002_update_trigger.rb 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. class UpdateTrigger < ActiveRecord::Migration
  2. def up
  3. # return if it's a new setup
  4. return if !Setting.find_by(name: 'system_init_done')
  5. Trigger.create_or_update(
  6. name: 'auto reply (on new tickets)',
  7. condition: {
  8. 'ticket.action' => {
  9. 'operator' => 'is',
  10. 'value' => 'create',
  11. },
  12. 'ticket.state_id' => {
  13. 'operator' => 'is not',
  14. 'value' => '4',
  15. },
  16. 'article.type_id' => {
  17. 'operator' => 'is',
  18. 'value' => [
  19. Ticket::Article::Type.lookup(name: 'email').id,
  20. Ticket::Article::Type.lookup(name: 'phone').id,
  21. Ticket::Article::Type.lookup(name: 'web').id,
  22. ],
  23. },
  24. },
  25. perform: {
  26. 'notification.email' => {
  27. 'body' => '<p>Your request (#{config.ticket_hook}#{ticket.number}) has been received and will be reviewed by our support staff.<p>
  28. <br/>
  29. <p>To provide additional information, please reply to this email or click on the following link:
  30. <a href="#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}">#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}</a>
  31. </p>
  32. <br/>
  33. <p>Your #{config.product_name} Team</p>
  34. <br/>
  35. <p><i><a href="http://zammad.com">Zammad</a>, your customer support system</i></p>',
  36. 'recipient' => 'ticket_customer',
  37. 'subject' => 'Thanks for your inquiry (#{ticket.title})',
  38. },
  39. },
  40. active: false,
  41. created_by_id: 1,
  42. updated_by_id: 1,
  43. )
  44. Trigger.create_or_update(
  45. name: 'auto reply (on follow up of tickets)',
  46. condition: {
  47. 'ticket.action' => {
  48. 'operator' => 'is',
  49. 'value' => 'update',
  50. },
  51. 'article.sender_id' => {
  52. 'operator' => 'is',
  53. 'value' => Ticket::Article::Sender.lookup(name: 'Customer').id,
  54. },
  55. 'article.type_id' => {
  56. 'operator' => 'is',
  57. 'value' => [
  58. Ticket::Article::Type.lookup(name: 'email').id,
  59. Ticket::Article::Type.lookup(name: 'phone').id,
  60. Ticket::Article::Type.lookup(name: 'web').id,
  61. ],
  62. },
  63. },
  64. perform: {
  65. 'notification.email' => {
  66. 'body' => '<p>Your follow up for (#{config.ticket_hook}#{ticket.number}) has been received and will be reviewed by our support staff.<p>
  67. <br/>
  68. <p>To provide additional information, please reply to this email or click on the following link:
  69. <a href="#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}">#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}</a>
  70. </p>
  71. <br/>
  72. <p>Your #{config.product_name} Team</p>
  73. <br/>
  74. <p><i><a href="http://zammad.com">Zammad</a>, your customer support system</i></p>',
  75. 'recipient' => 'ticket_customer',
  76. 'subject' => 'Thanks for your follow up (#{ticket.title})',
  77. },
  78. },
  79. active: false,
  80. created_by_id: 1,
  81. updated_by_id: 1,
  82. )
  83. end
  84. end