ticket.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import type { Ticket } from '#shared/graphql/types.ts'
  3. import { i18n } from '#shared/i18n.ts'
  4. import type { ActivityMessageBuilder } from '../types.ts'
  5. const path = (metaObject: Ticket) => {
  6. return `tickets/${metaObject.internalId}`
  7. }
  8. const messageText = (
  9. type: string,
  10. authorName: string,
  11. metaObject?: Ticket,
  12. ): Maybe<string> => {
  13. if (!metaObject) {
  14. return i18n.t('You can no longer see the ticket.')
  15. }
  16. const objectTitle = metaObject.title || '-'
  17. switch (type) {
  18. case 'create':
  19. return i18n.t('%s created ticket |%s|', authorName, objectTitle)
  20. case 'update':
  21. return i18n.t('%s updated ticket |%s|', authorName, objectTitle)
  22. case 'reminder_reached':
  23. return i18n.t('Pending reminder reached for ticket |%s|', objectTitle)
  24. case 'escalation':
  25. return i18n.t('Ticket |%s| has escalated!', objectTitle)
  26. case 'escalation_warning':
  27. return i18n.t('Ticket |%s| will escalate soon!', objectTitle)
  28. case 'update.merged_into':
  29. return i18n.t('Ticket |%s| was merged into another ticket', objectTitle)
  30. case 'update.received_merge':
  31. return i18n.t('Another ticket was merged into ticket |%s|', objectTitle)
  32. default:
  33. return null
  34. }
  35. }
  36. export default <ActivityMessageBuilder>{
  37. path,
  38. messageText,
  39. model: 'Ticket',
  40. }