diff --git a/app/views/api/v1/accounts/conversations/attachments.json.jbuilder b/app/views/api/v1/accounts/conversations/attachments.json.jbuilder index e31980ea2..86c900fca 100644 --- a/app/views/api/v1/accounts/conversations/attachments.json.jbuilder +++ b/app/views/api/v1/accounts/conversations/attachments.json.jbuilder @@ -1 +1,10 @@ -json.payload @attachments.map(&:push_event_data) +json.payload @attachments do |attachment| + json.message_id attachment.push_event_data[:message_id] + json.thumb_url attachment.push_event_data[:thumb_url] + json.data_url attachment.push_event_data[:data_url] + json.file_size attachment.push_event_data[:file_size] + json.file_type attachment.push_event_data[:file_type] + json.extension attachment.push_event_data[:extension] + json.created_at attachment.message.created_at.to_i + json.sender attachment.message.sender.push_event_data if attachment.message.sender +end diff --git a/spec/controllers/api/v1/accounts/conversations_controller_spec.rb b/spec/controllers/api/v1/accounts/conversations_controller_spec.rb index d4929fea1..7578f0b7d 100644 --- a/spec/controllers/api/v1/accounts/conversations_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/conversations_controller_spec.rb @@ -753,6 +753,7 @@ RSpec.describe 'Conversations API', type: :request do expect(response).to have_http_status(:success) response_body = response.parsed_body expect(response_body['payload'].first['file_type']).to eq('image') + expect(response_body['payload'].first['sender']['id']).to eq(conversation.messages.last.sender.id) end it 'return the attachments if you are an agent with access to inbox' do