20160503000001_update_trigger.rb 2.9 KB

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