ticket-article.ts 925 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { i18n } from '#shared/i18n.ts'
  3. import type { TicketArticle } from '#shared/graphql/types.ts'
  4. import type { ActivityMessageBuilder } from '../types.ts'
  5. const path = (metaObject: TicketArticle) => {
  6. return `tickets/${metaObject.ticket.internalId}`
  7. }
  8. const messageText = (
  9. type: string,
  10. authorName: string,
  11. metaObject?: TicketArticle,
  12. ): Maybe<string> => {
  13. if (!metaObject) {
  14. return i18n.t('You can no longer see the ticket.')
  15. }
  16. const objectTitle = metaObject.ticket.title || '-'
  17. switch (type) {
  18. case 'create':
  19. return i18n.t('%s created article for |%s|', authorName, objectTitle)
  20. case 'update':
  21. return i18n.t('%s updated article for |%s|', authorName, objectTitle)
  22. default:
  23. return null
  24. }
  25. }
  26. export default <ActivityMessageBuilder>{
  27. messageText,
  28. path,
  29. model: 'Ticket::Article',
  30. }