Fix handling of edited status with new media and no text (#35970)
Some checks failed
JavaScript Linting / lint (push) Has been cancelled
Ruby Linting / lint (push) Has been cancelled
JavaScript Testing / test (push) Has been cancelled
Test one step migrations / pre_job (push) Has been cancelled
Test two step migrations / pre_job (push) Has been cancelled
Ruby Testing / build (production) (push) Has been cancelled
Ruby Testing / build (test) (push) Has been cancelled
Test one step migrations / test (14-alpine) (push) Has been cancelled
Test one step migrations / test (15-alpine) (push) Has been cancelled
Test two step migrations / test (14-alpine) (push) Has been cancelled
Test two step migrations / test (15-alpine) (push) Has been cancelled
Ruby Testing / test (1, .ruby-version) (push) Has been cancelled
Ruby Testing / test (1, 3.1) (push) Has been cancelled
Ruby Testing / test (1, 3.3) (push) Has been cancelled
Ruby Testing / test (2, .ruby-version) (push) Has been cancelled
Ruby Testing / test (2, 3.1) (push) Has been cancelled
Ruby Testing / test (2, 3.3) (push) Has been cancelled
Ruby Testing / test (3, .ruby-version) (push) Has been cancelled
Ruby Testing / test (3, 3.1) (push) Has been cancelled
Ruby Testing / test (3, 3.3) (push) Has been cancelled
Ruby Testing / test (4, .ruby-version) (push) Has been cancelled
Ruby Testing / test (4, 3.1) (push) Has been cancelled
Ruby Testing / test (4, 3.3) (push) Has been cancelled
Ruby Testing / End to End testing (.ruby-version) (push) Has been cancelled
Ruby Testing / End to End testing (3.1) (push) Has been cancelled
Ruby Testing / End to End testing (3.3) (push) Has been cancelled
Ruby Testing / Testing search (.ruby-version) (push) Has been cancelled
Ruby Testing / Testing search (3.1) (push) Has been cancelled
Ruby Testing / Testing search (3.3) (push) Has been cancelled

This commit is contained in:
fiona 2025-09-02 12:25:55 +00:00 committed by Claire
parent 30d4303345
commit 91de503285
2 changed files with 38 additions and 0 deletions

View File

@ -102,6 +102,8 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
@status.ordered_media_attachment_ids = @next_media_attachments.map(&:id)
@media_attachments_changed = true if @status.ordered_media_attachment_ids != previous_media_attachments_ids
@status.media_attachments.reload if @media_attachments_changed
end
def download_media_files!

View File

@ -368,6 +368,42 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
end
end
context 'when originally without media attachments and text is removed' do
before do
stub_request(:get, 'https://example.com/foo.png').to_return(body: attachment_fixture('emojo.png'))
end
let(:payload) do
{
'@context': 'https://www.w3.org/ns/activitystreams',
id: 'foo',
type: 'Note',
content: '',
updated: '2021-09-08T22:39:25Z',
attachment: [
{ type: 'Image', mediaType: 'image/png', url: 'https://example.com/foo.png' },
],
}
end
it 'updates media attachments, fetches attachment, records media and text removal in edit' do
subject.call(status, json, json)
expect(status.reload.ordered_media_attachments.first)
.to be_present
.and(have_attributes(remote_url: 'https://example.com/foo.png'))
expect(a_request(:get, 'https://example.com/foo.png'))
.to have_been_made
expect(status.edits.reload.last.ordered_media_attachment_ids)
.to_not be_empty
expect(status.edits.reload.last.text)
.to_not be_present
end
end
context 'when originally with media attachments' do
let(:media_attachments) { [Fabricate(:media_attachment, remote_url: 'https://example.com/foo.png'), Fabricate(:media_attachment, remote_url: 'https://example.com/unused.png')] }