telegram.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. const sender = article.sender?.name
  12. const type = article.type?.name
  13. if (
  14. sender !== EnumTicketArticleSenderName.Customer ||
  15. type !== 'telegram personal-message'
  16. )
  17. return []
  18. const action: TicketArticleAction = {
  19. apps: ['mobile', 'desktop'],
  20. label: __('Reply'),
  21. name: 'telegram personal-message',
  22. icon: 'reply',
  23. view: {
  24. agent: ['change'],
  25. },
  26. perform(ticket, article, { openReplyForm }) {
  27. const articleData = {
  28. articleType: type,
  29. inReplyTo: article.messageId,
  30. }
  31. openReplyForm(articleData)
  32. },
  33. }
  34. return [action]
  35. },
  36. addTypes(ticket) {
  37. const descriptionType = ticket.createArticleType?.name
  38. if (descriptionType !== 'telegram personal-message') return []
  39. const type: TicketArticleType = {
  40. apps: ['mobile', 'desktop'],
  41. value: 'telegram personal-message',
  42. label: __('Telegram'),
  43. buttonLabel: __('Add message'),
  44. icon: 'telegram',
  45. view: {
  46. agent: ['change'],
  47. },
  48. internal: false,
  49. contentType: 'text/plain',
  50. fields: {
  51. body: {
  52. required: true,
  53. validation: 'length:1,10000',
  54. },
  55. attachments: {},
  56. },
  57. editorMeta: {
  58. footer: {
  59. maxlength: 10000,
  60. warningLength: 5000,
  61. },
  62. },
  63. }
  64. return [type]
  65. },
  66. }
  67. export default actionPlugin