search_index.rb 847 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Chat::Session::SearchIndex
  3. extend ActiveSupport::Concern
  4. =begin
  5. lookup name of ref. objects
  6. chat_session = Chat::Session.find(123)
  7. result = chat_session.search_index_attribute_lookup
  8. returns
  9. attributes # object with lookup data
  10. =end
  11. def search_index_attribute_lookup(include_references: true)
  12. attributes = super
  13. return if !attributes
  14. attributes['tags'] = tag_list
  15. messages = Chat::Message.where(chat_session_id: id)
  16. attributes['messages'] = []
  17. messages.each do |message|
  18. # lookup attributes of ref. objects (normally name and note)
  19. message_attributes = message.search_index_attribute_lookup(include_references: false)
  20. attributes['messages'].push message_attributes
  21. end
  22. attributes
  23. end
  24. end