2019-08-14 09:48:44 +00:00
|
|
|
json.data do
|
|
|
|
json.meta do
|
2019-12-01 04:46:51 +00:00
|
|
|
json.mine_count @conversations_count[:mine_count]
|
|
|
|
json.unassigned_count @conversations_count[:unassigned_count]
|
|
|
|
json.all_count @conversations_count[:all_count]
|
2019-08-14 09:48:44 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
json.payload do
|
|
|
|
json.array! @conversations do |conversation|
|
|
|
|
json.meta do
|
|
|
|
json.sender do
|
2019-10-27 07:44:36 +00:00
|
|
|
json.id conversation.contact.id
|
2019-10-20 19:10:18 +00:00
|
|
|
json.name conversation.contact.name
|
|
|
|
json.thumbnail conversation.contact.avatar.thumb.url
|
2019-11-17 08:45:05 +00:00
|
|
|
json.channel conversation.inbox.try(:channel_type)
|
2019-08-14 09:48:44 +00:00
|
|
|
end
|
|
|
|
json.assignee conversation.assignee
|
|
|
|
end
|
|
|
|
|
|
|
|
json.id conversation.display_id
|
2019-10-20 19:10:18 +00:00
|
|
|
if conversation.unread_incoming_messages.count.zero?
|
2019-08-14 09:48:44 +00:00
|
|
|
json.messages [conversation.messages.last.try(:push_event_data)]
|
2019-10-20 08:47:26 +00:00
|
|
|
else
|
|
|
|
json.messages conversation.unread_messages.map(&:push_event_data)
|
2019-08-14 09:48:44 +00:00
|
|
|
end
|
2019-12-15 11:29:12 +00:00
|
|
|
json.inbox_id conversation.inbox_id
|
2019-08-14 09:48:44 +00:00
|
|
|
json.status conversation.status_before_type_cast
|
|
|
|
json.timestamp conversation.messages.last.try(:created_at).try(:to_i)
|
|
|
|
json.user_last_seen_at conversation.user_last_seen_at.to_i
|
|
|
|
json.agent_last_seen_at conversation.agent_last_seen_at.to_i
|
|
|
|
json.unread_count conversation.unread_incoming_messages.count
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|