user.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import type { User } from '#shared/graphql/types.ts'
  3. import { i18n } from '#shared/i18n.ts'
  4. import type { ActivityMessageBuilder } from '../types.ts'
  5. const path = (metaObject: User) => {
  6. return `users/${metaObject.internalId}`
  7. }
  8. const messageText = (
  9. type: string,
  10. authorName: string,
  11. metaObject?: User,
  12. ): Maybe<string> => {
  13. if (!metaObject) {
  14. return i18n.t('You can no longer see the user.')
  15. }
  16. const objectTitle = metaObject.fullname || '-'
  17. switch (type) {
  18. case 'create':
  19. return i18n.t('%s created user |%s|', authorName, objectTitle)
  20. case 'update':
  21. return i18n.t('%s updated user |%s|', authorName, objectTitle)
  22. case 'session started':
  23. return i18n.t('%s started a new session', authorName)
  24. case 'switch to':
  25. return i18n.t('%s switched to |%s|!', authorName, objectTitle)
  26. case 'ended switch to':
  27. return i18n.t('%s ended switch to |%s|!', authorName, objectTitle)
  28. default:
  29. return null
  30. }
  31. }
  32. export default <ActivityMessageBuilder>{
  33. messageText,
  34. path,
  35. model: 'User',
  36. }