sms.ts 1.7 KB

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