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