791d90c6b7
At present, the websocket pubsub tokens are present at the contact objects in chatwoot. A better approach would be to have these tokens at the contact_inbox object instead. This helps chatwoot to deliver the websocket events targetted to the specific widget connection, stop contact events from leaking into other chat sessions from the same contact. Fixes #1682 Fixes #1664 Co-authored-by: Pranav Raj S <pranav@chatwoot.com> Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
41 lines
1.6 KiB
Ruby
41 lines
1.6 KiB
Ruby
json.meta do
|
|
json.sender do
|
|
json.partial! 'api/v1/models/contact.json.jbuilder', resource: conversation.contact
|
|
end
|
|
json.channel conversation.inbox.try(:channel_type)
|
|
if conversation.assignee&.account
|
|
json.assignee do
|
|
json.partial! 'api/v1/models/agent.json.jbuilder', resource: conversation.assignee
|
|
end
|
|
end
|
|
if conversation.team.present?
|
|
json.team do
|
|
json.partial! 'api/v1/models/team.json.jbuilder', resource: conversation.team
|
|
end
|
|
end
|
|
json.hmac_verified conversation.contact_inbox&.hmac_verified
|
|
end
|
|
|
|
json.id conversation.display_id
|
|
if conversation.messages.count.zero?
|
|
json.messages []
|
|
elsif conversation.unread_incoming_messages.count.zero?
|
|
json.messages [conversation.messages.includes([{ attachments: [{ file_attachment: [:blob] }] }]).last.try(:push_event_data)]
|
|
else
|
|
json.messages conversation.unread_messages.includes([:user, { attachments: [{ file_attachment: [:blob] }] }]).last(10).map(&:push_event_data)
|
|
end
|
|
|
|
json.account_id conversation.account_id
|
|
json.additional_attributes conversation.additional_attributes
|
|
json.agent_last_seen_at conversation.agent_last_seen_at.to_i
|
|
json.assignee_last_seen_at conversation.assignee_last_seen_at.to_i
|
|
json.can_reply conversation.can_reply?
|
|
json.contact_last_seen_at conversation.contact_last_seen_at.to_i
|
|
json.custom_attributes conversation.custom_attributes
|
|
json.inbox_id conversation.inbox_id
|
|
json.labels conversation.label_list
|
|
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
|