From 5c99805fe234e37d756742d1eb4412ec66ea57b6 Mon Sep 17 00:00:00 2001 From: Gabriel Jablonski Date: Thu, 29 Jan 2026 16:12:45 -0300 Subject: [PATCH] feat: include attachment ID in the JSON response for attachments (#201) * feat: include attachment ID in the JSON response for attachments * test: verify attachment ID in conversation response payload --- .../api/v1/accounts/conversations/attachments.json.jbuilder | 1 + .../controllers/api/v1/accounts/conversations_controller_spec.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/app/views/api/v1/accounts/conversations/attachments.json.jbuilder b/app/views/api/v1/accounts/conversations/attachments.json.jbuilder index 167b18390..8bd647f27 100644 --- a/app/views/api/v1/accounts/conversations/attachments.json.jbuilder +++ b/app/views/api/v1/accounts/conversations/attachments.json.jbuilder @@ -3,6 +3,7 @@ json.meta do end json.payload @attachments do |attachment| + json.id attachment.push_event_data[:id] 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] diff --git a/spec/controllers/api/v1/accounts/conversations_controller_spec.rb b/spec/controllers/api/v1/accounts/conversations_controller_spec.rb index ee3e77dc6..0510a5347 100644 --- a/spec/controllers/api/v1/accounts/conversations_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/conversations_controller_spec.rb @@ -953,6 +953,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['id']).to eq(conversation.messages.last.attachments.first.id) 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