20160503000002_update_trigger.rb 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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' => Ticket::State.lookup(name: 'closed').id,
  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. 'article.sender_id' => {
  25. 'operator' => 'is',
  26. 'value' => Ticket::Article::Sender.lookup(name: 'Customer').id,
  27. },
  28. },
  29. perform: {
  30. 'notification.email' => {
  31. 'body' => '<p>Your request (#{config.ticket_hook}#{ticket.number}) has been received and will be reviewed by our support staff.<p>
  32. <br/>
  33. <p>To provide additional information, please reply to this email or click on the following link:
  34. <a href="#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}">#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}</a>
  35. </p>
  36. <br/>
  37. <p>Your #{config.product_name} Team</p>
  38. <br/>
  39. <p><i><a href="http://zammad.com">Zammad</a>, your customer support system</i></p>',
  40. 'recipient' => 'ticket_customer',
  41. 'subject' => 'Thanks for your inquiry (#{ticket.title})',
  42. },
  43. },
  44. active: false,
  45. created_by_id: 1,
  46. updated_by_id: 1,
  47. )
  48. Trigger.create_or_update(
  49. name: 'auto reply (on follow up of tickets)',
  50. condition: {
  51. 'ticket.action' => {
  52. 'operator' => 'is',
  53. 'value' => 'update',
  54. },
  55. 'article.sender_id' => {
  56. 'operator' => 'is',
  57. 'value' => Ticket::Article::Sender.lookup(name: 'Customer').id,
  58. },
  59. 'article.type_id' => {
  60. 'operator' => 'is',
  61. 'value' => [
  62. Ticket::Article::Type.lookup(name: 'email').id,
  63. Ticket::Article::Type.lookup(name: 'phone').id,
  64. Ticket::Article::Type.lookup(name: 'web').id,
  65. ],
  66. },
  67. },
  68. perform: {
  69. 'notification.email' => {
  70. 'body' => '<p>Your follow up for (#{config.ticket_hook}#{ticket.number}) has been received and will be reviewed by our support staff.<p>
  71. <br/>
  72. <p>To provide additional information, please reply to this email or click on the following link:
  73. <a href="#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}">#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}</a>
  74. </p>
  75. <br/>
  76. <p>Your #{config.product_name} Team</p>
  77. <br/>
  78. <p><i><a href="http://zammad.com">Zammad</a>, your customer support system</i></p>',
  79. 'recipient' => 'ticket_customer',
  80. 'subject' => 'Thanks for your follow up (#{ticket.title})',
  81. },
  82. },
  83. active: false,
  84. created_by_id: 1,
  85. updated_by_id: 1,
  86. )
  87. end
  88. end