mattermost.rb 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Webhook::PreDefined::Mattermost < Webhook::PreDefined
  3. def name
  4. __('Mattermost Notifications')
  5. end
  6. # rubocop:disable Lint/InterpolationCheck
  7. def custom_payload
  8. {
  9. channel: '#{webhook.messaging_channel}',
  10. username: '#{webhook.messaging_username}',
  11. icon_url: '#{webhook.messaging_icon_url}',
  12. mrkdwn: true,
  13. text: '# #{ticket.title}',
  14. attachments: [
  15. {
  16. text: "_[Ticket#\#{ticket.number}](\#{notification.link}): \#{notification.message}_\n\n\#{notification.changes}\n\n\#{notification.body}",
  17. mrkdwn_in: [
  18. 'text'
  19. ],
  20. color: '#{ticket.current_state_color}'
  21. }
  22. ]
  23. }
  24. end
  25. # rubocop:enable Lint/InterpolationCheck
  26. def fields
  27. [
  28. {
  29. display: __('Messaging Username'),
  30. placeholder: '',
  31. null: true,
  32. name: 'messaging_username',
  33. tag: 'input',
  34. },
  35. {
  36. display: __('Messaging Channel'),
  37. placeholder: '#channel',
  38. null: true,
  39. name: 'messaging_channel',
  40. tag: 'input',
  41. },
  42. {
  43. display: __('Messaging Icon URL'),
  44. placeholder: 'https://example.com/logo.png',
  45. value: 'https://zammad.com/assets/images/logo-200x200.png',
  46. null: true,
  47. name: 'messaging_icon_url',
  48. tag: 'input',
  49. },
  50. ]
  51. end
  52. end