telegram.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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'],
  20. label: __('Reply'),
  21. name: 'telegram personal-message',
  22. icon: 'reply',
  23. view: {
  24. agent: ['change'],
  25. },
  26. perform(ticket, article, { openReplyDialog }) {
  27. const articleData = {
  28. articleType: type,
  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 !== 'telegram personal-message') return []
  39. const type: TicketArticleType = {
  40. apps: ['mobile'],
  41. value: 'telegram personal-message',
  42. label: __('Telegram'),
  43. icon: 'telegram',
  44. view: {
  45. agent: ['change'],
  46. },
  47. internal: false,
  48. contentType: 'text/plain',
  49. fields: {
  50. body: {
  51. required: true,
  52. validation: 'length:1,10000',
  53. },
  54. attachments: {},
  55. },
  56. editorMeta: {
  57. footer: {
  58. maxlength: 10000,
  59. warningLength: 5000,
  60. },
  61. },
  62. }
  63. return [type]
  64. },
  65. }
  66. export default actionPlugin