2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2017-12-18 03:36:56 +00:00
|
|
|
module Chat::Session::SearchIndex
|
2018-04-26 08:55:53 +00:00
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
2017-12-18 03:36:56 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
lookup name of ref. objects
|
|
|
|
|
|
|
|
chat_session = Chat::Session.find(123)
|
|
|
|
result = chat_session.search_index_attribute_lookup
|
|
|
|
|
|
|
|
returns
|
|
|
|
|
|
|
|
attributes # object with lookup data
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
2021-01-27 09:58:35 +00:00
|
|
|
def search_index_attribute_lookup(include_references: true)
|
2020-07-10 13:30:44 +00:00
|
|
|
attributes = super
|
|
|
|
return if !attributes
|
2017-12-18 03:36:56 +00:00
|
|
|
|
2020-07-10 13:30:44 +00:00
|
|
|
attributes['tags'] = tag_list
|
2017-12-18 03:36:56 +00:00
|
|
|
|
2020-07-10 13:30:44 +00:00
|
|
|
messages = Chat::Message.where(chat_session_id: id)
|
|
|
|
attributes['messages'] = []
|
|
|
|
messages.each do |message|
|
2017-12-18 03:36:56 +00:00
|
|
|
|
2020-07-10 13:30:44 +00:00
|
|
|
# lookup attributes of ref. objects (normally name and note)
|
2021-06-24 12:58:16 +00:00
|
|
|
message_attributes = message.search_index_attribute_lookup(include_references: false)
|
2017-12-18 03:36:56 +00:00
|
|
|
|
2020-07-10 13:30:44 +00:00
|
|
|
attributes['messages'].push message_attributes
|
2018-04-26 08:55:53 +00:00
|
|
|
end
|
2020-07-10 13:30:44 +00:00
|
|
|
|
|
|
|
attributes
|
2017-12-18 03:36:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|