2020-03-05 20:17:37 +00:00
|
|
|
json.meta do
|
|
|
|
json.sender do
|
2020-07-04 14:16:17 +00:00
|
|
|
json.partial! 'api/v1/models/contact.json.jbuilder', resource: conversation.contact
|
2020-03-05 20:17:37 +00:00
|
|
|
end
|
2020-07-04 14:16:17 +00:00
|
|
|
json.channel conversation.inbox.try(:channel_type)
|
2020-12-08 17:19:47 +00:00
|
|
|
if conversation.assignee&.account
|
2020-07-27 16:49:26 +00:00
|
|
|
json.assignee do
|
2020-10-10 16:27:09 +00:00
|
|
|
json.partial! 'api/v1/models/agent.json.jbuilder', resource: conversation.assignee
|
2020-07-27 16:49:26 +00:00
|
|
|
end
|
|
|
|
end
|
2021-03-15 13:07:03 +00:00
|
|
|
if conversation.team.present?
|
|
|
|
json.team do
|
|
|
|
json.partial! 'api/v1/models/team.json.jbuilder', resource: conversation.team
|
|
|
|
end
|
|
|
|
end
|
2020-03-05 20:17:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
json.id conversation.display_id
|
2021-01-31 07:35:07 +00:00
|
|
|
if conversation.messages.count.zero?
|
|
|
|
json.messages []
|
|
|
|
elsif conversation.unread_incoming_messages.count.zero?
|
2020-09-19 07:16:34 +00:00
|
|
|
json.messages [conversation.messages.includes([{ attachments: [{ file_attachment: [:blob] }] }]).last.try(:push_event_data)]
|
2020-03-05 20:17:37 +00:00
|
|
|
else
|
2020-12-10 18:00:38 +00:00
|
|
|
json.messages conversation.unread_messages.includes([:user, { attachments: [{ file_attachment: [:blob] }] }]).last(10).map(&:push_event_data)
|
2020-03-05 20:17:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
json.inbox_id conversation.inbox_id
|
|
|
|
json.status conversation.status
|
2020-05-26 12:13:59 +00:00
|
|
|
json.muted conversation.muted?
|
2020-07-25 17:24:45 +00:00
|
|
|
json.can_reply conversation.can_reply?
|
2020-10-05 17:22:43 +00:00
|
|
|
json.timestamp conversation.last_activity_at.to_i
|
2020-09-10 13:49:15 +00:00
|
|
|
json.contact_last_seen_at conversation.contact_last_seen_at.to_i
|
2020-03-05 20:17:37 +00:00
|
|
|
json.agent_last_seen_at conversation.agent_last_seen_at.to_i
|
|
|
|
json.unread_count conversation.unread_incoming_messages.count
|
|
|
|
json.additional_attributes conversation.additional_attributes
|
2020-04-10 11:12:37 +00:00
|
|
|
json.account_id conversation.account_id
|
2020-06-25 15:34:03 +00:00
|
|
|
json.labels conversation.label_list
|