search_index.rb 949 B

12345678910111213141516171819202122232425262728293031
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class User
  3. module SearchIndex
  4. extend ActiveSupport::Concern
  5. def search_index_attribute_lookup(include_references: true)
  6. attributes = super
  7. attributes['fullname'] = fullname
  8. attributes.delete('password')
  9. if include_references
  10. attributes['permissions'] = []
  11. permissions_with_child_ids.each do |permission_id|
  12. permission = ::Permission.lookup(id: permission_id)
  13. next if !permission
  14. attributes['permissions'].push permission.name
  15. end
  16. attributes['role_ids'] = role_ids
  17. attributes['organization_ids'] = organization_ids
  18. attributes['organizations'] = organizations.each_with_object([]) do |organization, result|
  19. result << organization.search_index_attribute_lookup(include_references: false)
  20. end
  21. end
  22. attributes
  23. end
  24. end
  25. end