sms.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. import type {
  3. TicketArticleAction,
  4. TicketArticleActionPlugin,
  5. TicketArticleType,
  6. } from './types'
  7. const actionPlugin: TicketArticleActionPlugin = {
  8. order: 300,
  9. addActions(ticket, article) {
  10. if (article.sender?.name !== 'Customer' || article.type?.name !== 'sms')
  11. return []
  12. const action: TicketArticleAction = {
  13. apps: ['mobile'],
  14. label: __('Reply'),
  15. name: 'sms',
  16. icon: {
  17. mobile: 'mobile-reply',
  18. },
  19. view: {
  20. agent: ['change'],
  21. },
  22. perform(ticket, article, { openReplyDialog }) {
  23. const from = article.from?.raw
  24. const articleData = {
  25. articleType: 'sms',
  26. to: from ? [from] : [],
  27. inReplyTo: article.messageId,
  28. }
  29. openReplyDialog(articleData)
  30. },
  31. }
  32. return [action]
  33. },
  34. addTypes(ticket) {
  35. const descriptionType = ticket.createArticleType?.name
  36. if (descriptionType !== 'sms') return []
  37. const type: TicketArticleType = {
  38. apps: ['mobile'],
  39. value: 'sms',
  40. label: __('Sms'),
  41. icon: {
  42. mobile: 'mobile-message',
  43. },
  44. view: {
  45. agent: ['change'],
  46. },
  47. attributes: ['to'],
  48. internal: false,
  49. recipientContact: 'phone',
  50. contentType: 'text/plain',
  51. editorMeta: {
  52. footer: {
  53. maxlength: 160,
  54. warningLength: 30,
  55. },
  56. },
  57. }
  58. return [type]
  59. },
  60. }
  61. export default actionPlugin