mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-07 10:22:48 +00:00
Fix handling of edited status with new media and no text (#35970)
This commit is contained in:
parent
bdff970a5e
commit
e665cc68f4
|
@ -112,6 +112,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!
|
||||
|
|
|
@ -343,6 +343,42 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService 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')] }
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user