search_index.rb 1012 B

1234567891011121314151617181920212223242526272829303132
  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. attributes['preferences']&.delete('signature_detection')
  10. if include_references
  11. attributes['permissions'] = []
  12. permissions_with_child_ids.each do |permission_id|
  13. permission = ::Permission.lookup(id: permission_id)
  14. next if !permission
  15. attributes['permissions'].push permission.name
  16. end
  17. attributes['role_ids'] = role_ids
  18. attributes['organization_ids'] = organization_ids
  19. attributes['organizations'] = organizations.each_with_object([]) do |organization, result|
  20. result << organization.search_index_attribute_lookup(include_references: false)
  21. end
  22. end
  23. attributes
  24. end
  25. end
  26. end