diff --git a/app/controllers/api/v1/accounts/contacts/conversations_controller.rb b/app/controllers/api/v1/accounts/contacts/conversations_controller.rb index 5c7bf77d7..8a9199b6b 100644 --- a/app/controllers/api/v1/accounts/contacts/conversations_controller.rb +++ b/app/controllers/api/v1/accounts/contacts/conversations_controller.rb @@ -1,7 +1,7 @@ class Api::V1::Accounts::Contacts::ConversationsController < Api::V1::Accounts::BaseController def index @conversations = Current.account.conversations.includes( - :assignee, :contact, :inbox + :assignee, :contact, :inbox, :taggings ).where(inbox_id: inbox_ids, contact_id: permitted_params[:contact_id]) end diff --git a/app/controllers/api/v1/accounts/contacts_controller.rb b/app/controllers/api/v1/accounts/contacts_controller.rb index 87b3898f1..34ac91b3a 100644 --- a/app/controllers/api/v1/accounts/contacts_controller.rb +++ b/app/controllers/api/v1/accounts/contacts_controller.rb @@ -63,6 +63,6 @@ class Api::V1::Accounts::ContactsController < Api::V1::Accounts::BaseController end def fetch_contact - @contact = Current.account.contacts.find(params[:id]) + @contact = Current.account.contacts.includes(contact_inboxes: [:inbox]).find(params[:id]) end end diff --git a/app/finders/conversation_finder.rb b/app/finders/conversation_finder.rb index 5ca1e12f6..183c9b535 100644 --- a/app/finders/conversation_finder.rb +++ b/app/finders/conversation_finder.rb @@ -62,7 +62,7 @@ class ConversationFinder def find_all_conversations @conversations = current_account.conversations.includes( - :assignee, :inbox, contact: [:avatar_attachment] + :assignee, :inbox, :taggings, contact: [:avatar_attachment] ).where(inbox_id: @inbox_ids) end diff --git a/app/finders/message_finder.rb b/app/finders/message_finder.rb index 00ef8ab3b..5295dce74 100644 --- a/app/finders/message_finder.rb +++ b/app/finders/message_finder.rb @@ -11,7 +11,7 @@ class MessageFinder private def conversation_messages - @conversation.messages.includes(:attachments, user: { avatar_attachment: :blob }) + @conversation.messages.includes(:attachments, :sender) end def messages diff --git a/app/views/api/v1/conversations/partials/_conversation.json.jbuilder b/app/views/api/v1/conversations/partials/_conversation.json.jbuilder index deae107c1..d9068fe26 100644 --- a/app/views/api/v1/conversations/partials/_conversation.json.jbuilder +++ b/app/views/api/v1/conversations/partials/_conversation.json.jbuilder @@ -12,9 +12,9 @@ end json.id conversation.display_id if conversation.unread_incoming_messages.count.zero? - json.messages [conversation.messages.last.try(:push_event_data)] + json.messages [conversation.messages.includes([{ attachments: [{ file_attachment: [:blob] }] }]).last.try(:push_event_data)] else - json.messages conversation.unread_messages.includes([:user, :attachments]).map(&:push_event_data) + json.messages conversation.unread_messages.includes([:user, { attachments: [{ file_attachment: [:blob] }] }]).map(&:push_event_data) end json.inbox_id conversation.inbox_id