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
|
2021-11-22 18:02:17 +00:00
|
|
|
json.hmac_verified conversation.contact_inbox&.hmac_verified
|
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
|
|
|
|
|
2021-09-29 14:03:51 +00:00
|
|
|
json.account_id conversation.account_id
|
|
|
|
json.additional_attributes conversation.additional_attributes
|
2020-03-05 20:17:37 +00:00
|
|
|
json.agent_last_seen_at conversation.agent_last_seen_at.to_i
|
2021-09-23 15:29:10 +00:00
|
|
|
json.assignee_last_seen_at conversation.assignee_last_seen_at.to_i
|
2021-09-29 14:03:51 +00:00
|
|
|
json.can_reply conversation.can_reply?
|
|
|
|
json.contact_last_seen_at conversation.contact_last_seen_at.to_i
|
2021-09-22 05:16:48 +00:00
|
|
|
json.custom_attributes conversation.custom_attributes
|
2021-09-29 14:03:51 +00:00
|
|
|
json.inbox_id conversation.inbox_id
|
2020-06-25 15:34:03 +00:00
|
|
|
json.labels conversation.label_list
|
2021-09-29 14:03:51 +00:00
|
|
|
json.muted conversation.muted?
|
|
|
|
json.snoozed_until conversation.snoozed_until
|
|
|
|
json.status conversation.status
|
|
|
|
json.timestamp conversation.last_activity_at.to_i
|
|
|
|
json.unread_count conversation.unread_incoming_messages.count
|