From d17fb7013116767fc5c7d5eef63218bd8c45b023 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 9 Mar 2022 09:06:17 +0100 Subject: Change how changes to media attachments are stored for edits (#17696) * Change how changes to media attachments are stored for edits Fix not being able to re-order media attachments * Fix not broadcasting updates when polls/media is changed through ActivityPub * Various fixes and improvements * Update app/models/report.rb Co-authored-by: Claire * Add tracking of media attachment description changes * Change poll in status edit to have a structure closer to the real one Co-authored-by: Claire --- .../activitypub/process_status_update_service_spec.rb | 17 ++++++----------- spec/services/update_status_service_spec.rb | 14 +++++++------- 2 files changed, 13 insertions(+), 18 deletions(-) (limited to 'spec/services') diff --git a/spec/services/activitypub/process_status_update_service_spec.rb b/spec/services/activitypub/process_status_update_service_spec.rb index 6ee1dcb43..40b405217 100644 --- a/spec/services/activitypub/process_status_update_service_spec.rb +++ b/spec/services/activitypub/process_status_update_service_spec.rb @@ -124,7 +124,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do end it 'updates media attachments' do - media_attachment = status.media_attachments.reload.first + media_attachment = status.reload.ordered_media_attachments.first expect(media_attachment).to_not be_nil expect(media_attachment.remote_url).to eq 'https://example.com/foo.png' @@ -135,7 +135,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do end it 'records media change in edit' do - expect(status.edits.reload.last.media_attachments_changed).to be true + expect(status.edits.reload.last.ordered_media_attachment_ids).to_not be_empty end end @@ -173,11 +173,11 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do end it 'updates media attachments' do - expect(status.media_attachments.reload.map(&:remote_url)).to eq %w(https://example.com/foo.png) + expect(status.ordered_media_attachments.map(&:remote_url)).to eq %w(https://example.com/foo.png) end it 'records media change in edit' do - expect(status.edits.reload.last.media_attachments_changed).to be true + expect(status.edits.reload.last.ordered_media_attachment_ids).to_not be_empty end end @@ -193,7 +193,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do end it 'records media change in edit' do - expect(status.edits.reload.last.media_attachments_changed).to be true + expect(status.edits.reload.last.poll_options).to be_nil end end @@ -226,7 +226,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do end it 'records media change in edit' do - expect(status.edits.reload.last.media_attachments_changed).to be true + expect(status.edits.reload.last.poll_options).to eq %w(Foo Bar Baz) end end @@ -239,10 +239,5 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do subject.call(status, json) expect(status.reload.edited_at.to_s).to eq '2021-09-08 22:39:25 UTC' end - - it 'records that no media has been changed in edit' do - subject.call(status, json) - expect(status.edits.reload.last.media_attachments_changed).to be false - end end end diff --git a/spec/services/update_status_service_spec.rb b/spec/services/update_status_service_spec.rb index 4fd4837c6..78cc89cd4 100644 --- a/spec/services/update_status_service_spec.rb +++ b/spec/services/update_status_service_spec.rb @@ -21,7 +21,7 @@ RSpec.describe UpdateStatusService, type: :service do end it 'saves edit history' do - expect(status.edits.pluck(:text, :media_attachments_changed)).to eq [['Foo', false], ['Bar', false]] + expect(status.edits.pluck(:text)).to eq %w(Foo Bar) end end @@ -39,7 +39,7 @@ RSpec.describe UpdateStatusService, type: :service do end it 'saves edit history' do - expect(status.edits.pluck(:text, :spoiler_text, :media_attachments_changed)).to eq [['Foo', '', false], ['Foo', 'Bar', false]] + expect(status.edits.pluck(:text, :spoiler_text)).to eq [['Foo', ''], ['Foo', 'Bar']] end end @@ -54,11 +54,11 @@ RSpec.describe UpdateStatusService, type: :service do end it 'updates media attachments' do - expect(status.media_attachments.to_a).to eq [attached_media_attachment] + expect(status.ordered_media_attachments).to eq [attached_media_attachment] end - it 'detaches detached media attachments' do - expect(detached_media_attachment.reload.status_id).to be_nil + it 'does not detach detached media attachments' do + expect(detached_media_attachment.reload.status_id).to eq status.id end it 'attaches attached media attachments' do @@ -66,7 +66,7 @@ RSpec.describe UpdateStatusService, type: :service do end it 'saves edit history' do - expect(status.edits.pluck(:text, :media_attachments_changed)).to eq [['Foo', false], ['Foo', true]] + expect(status.edits.pluck(:ordered_media_attachment_ids)).to eq [[detached_media_attachment.id], [attached_media_attachment.id]] end end @@ -95,7 +95,7 @@ RSpec.describe UpdateStatusService, type: :service do end it 'saves edit history' do - expect(status.edits.pluck(:text, :media_attachments_changed)).to eq [['Foo', false], ['Foo', true]] + expect(status.edits.pluck(:poll_options)).to eq [%w(Foo Bar), %w(Bar Baz Foo)] end end -- cgit From 63c9d2bc2881391496d372cc5166afb1662b841a Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 10 Mar 2022 00:11:40 +0100 Subject: Add tests for CVE-2022-24307 (#17733) Follow-up to #17426 --- .../activitypub/process_collection_service_spec.rb | 140 +++++++++++++++++++++ 1 file changed, 140 insertions(+) (limited to 'spec/services') diff --git a/spec/services/activitypub/process_collection_service_spec.rb b/spec/services/activitypub/process_collection_service_spec.rb index 00d71a86a..3eccaab5b 100644 --- a/spec/services/activitypub/process_collection_service_spec.rb +++ b/spec/services/activitypub/process_collection_service_spec.rb @@ -91,6 +91,146 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do subject.call(json, forwarder) end + + context 'when receiving a fabricated status' do + let!(:actor) do + Fabricate(:account, + username: 'bob', + domain: 'example.com', + uri: 'https://example.com/users/bob', + public_key: "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuuYyoyfsRkYnXRotMsId\nW3euBDDfiv9oVqOxUVC7bhel8KednIMrMCRWFAkgJhbrlzbIkjVr68o1MP9qLcn7\nCmH/BXHp7yhuFTr4byjdJKpwB+/i2jNEsvDH5jR8WTAeTCe0x/QHg21V3F7dSI5m\nCCZ/1dSIyOXLRTWVlfDlm3rE4ntlCo+US3/7oSWbg/4/4qEnt1HC32kvklgScxua\n4LR5ATdoXa5bFoopPWhul7MJ6NyWCyQyScUuGdlj8EN4kmKQJvphKHrI9fvhgOuG\nTvhTR1S5InA4azSSchY0tXEEw/VNxraeX0KPjbgr6DPcwhPd/m0nhVDq0zVyVBBD\nMwIDAQAB\n-----END PUBLIC KEY-----\n", + private_key: nil) + end + + let(:payload) do + { + '@context': [ + 'https://www.w3.org/ns/activitystreams', + nil, + {'object': 'https://www.w3.org/ns/activitystreams#object'} + ], + 'id': 'https://example.com/users/bob/fake-status/activity', + 'type': 'Create', + 'actor': 'https://example.com/users/bob', + 'published': '2022-01-22T15:00:00Z', + 'to': [ + 'https://www.w3.org/ns/activitystreams#Public' + ], + 'cc': [ + 'https://example.com/users/bob/followers' + ], + 'signature': { + 'type': 'RsaSignature2017', + 'creator': 'https://example.com/users/bob#main-key', + 'created': '2022-03-09T21:57:25Z', + 'signatureValue': 'WculK0LelTQ0MvGwU9TPoq5pFzFfGYRDCJqjZ232/Udj4CHqDTGOSw5UTDLShqBOyycCkbZGrQwXG+dpyDpQLSe1UVPZ5TPQtc/9XtI57WlS2nMNpdvRuxGnnb2btPdesXZ7n3pCxo0zjaXrJMe0mqQh5QJO22mahb4bDwwmfTHgbD3nmkD+fBfGi+UV2qWwqr+jlV4L4JqNkh0gWljF5KTePLRRZCuWiQ/FAt7c67636cdIPf7fR+usjuZltTQyLZKEGuK8VUn2Gkfsx5qns7Vcjvlz1JqlAjyO8HPBbzTTHzUG2nUOIgC3PojCSWv6mNTmRGoLZzOscCAYQA6cKw==' + }, + '@id': 'https://example.com/users/bob/statuses/107928807471117876/activity', + '@type': 'https://www.w3.org/ns/activitystreams#Create', + 'https://www.w3.org/ns/activitystreams#actor': { + '@id': 'https://example.com/users/bob' + }, + 'https://www.w3.org/ns/activitystreams#cc': { + '@id': 'https://example.com/users/bob/followers' + }, + 'object': { + 'id': 'https://example.com/users/bob/fake-status', + 'type': 'Note', + 'published': '2022-01-22T15:00:00Z', + 'url': 'https://www.youtube.com/watch?v=dQw4w9WgXcQ&feature=puck-was-here', + 'attributedTo': 'https://example.com/users/bob', + 'to': [ + 'https://www.w3.org/ns/activitystreams#Public' + ], + 'cc': [ + 'https://example.com/users/bob/followers' + ], + 'sensitive': false, + 'atomUri': 'https://example.com/users/bob/fake-status', + 'conversation': 'tag:example.com,2022-03-09:objectId=15:objectType=Conversation', + 'content': '

puck was here

', + + '@id': 'https://example.com/users/bob/statuses/107928807471117876', + '@type': 'https://www.w3.org/ns/activitystreams#Note', + 'http://ostatus.org#atomUri': 'https://example.com/users/bob/statuses/107928807471117876', + 'http://ostatus.org#conversation': 'tag:example.com,2022-03-09:objectId=15:objectType=Conversation', + 'https://www.w3.org/ns/activitystreams#attachment': [], + 'https://www.w3.org/ns/activitystreams#attributedTo': { + '@id': 'https://example.com/users/bob' + }, + 'https://www.w3.org/ns/activitystreams#cc': { + '@id': 'https://example.com/users/bob/followers' + }, + 'https://www.w3.org/ns/activitystreams#content': [ + '

hello world

', + { + '@value': '

hello world

', + '@language': 'en' + } + ], + 'https://www.w3.org/ns/activitystreams#published': { + '@type': 'http://www.w3.org/2001/XMLSchema#dateTime', + '@value': '2022-03-09T21:55:07Z' + }, + 'https://www.w3.org/ns/activitystreams#replies': { + '@id': 'https://example.com/users/bob/statuses/107928807471117876/replies', + '@type': 'https://www.w3.org/ns/activitystreams#Collection', + 'https://www.w3.org/ns/activitystreams#first': { + '@type': 'https://www.w3.org/ns/activitystreams#CollectionPage', + 'https://www.w3.org/ns/activitystreams#items': [], + 'https://www.w3.org/ns/activitystreams#next': { + '@id': 'https://example.com/users/bob/statuses/107928807471117876/replies?only_other_accounts=true&page=true' + }, + 'https://www.w3.org/ns/activitystreams#partOf': { + '@id': 'https://example.com/users/bob/statuses/107928807471117876/replies' + } + } + }, + 'https://www.w3.org/ns/activitystreams#sensitive': false, + 'https://www.w3.org/ns/activitystreams#tag': [], + 'https://www.w3.org/ns/activitystreams#to': { + '@id': 'https://www.w3.org/ns/activitystreams#Public' + }, + 'https://www.w3.org/ns/activitystreams#url': { + '@id': 'https://example.com/@bob/107928807471117876' + } + }, + 'https://www.w3.org/ns/activitystreams#published': { + '@type': 'http://www.w3.org/2001/XMLSchema#dateTime', + '@value': '2022-03-09T21:55:07Z' + }, + 'https://www.w3.org/ns/activitystreams#to': { + '@id': 'https://www.w3.org/ns/activitystreams#Public' + } + } + end + + it 'does not process forged payload' do + expect(ActivityPub::Activity).not_to receive(:factory).with( + hash_including( + 'object' => hash_including( + 'id' => 'https://example.com/users/bob/fake-status' + ) + ), + anything(), + anything() + ) + + expect(ActivityPub::Activity).not_to receive(:factory).with( + hash_including( + 'object' => hash_including( + 'content' => '

puck was here

' + ) + ), + anything(), + anything() + ) + + subject.call(json, forwarder) + + expect(Status.where(uri: 'https://example.com/users/bob/fake-status').exists?).to be false + end + end end end end -- cgit From 5ccd6cbfda84463a90b55be077da13498e1cc293 Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 10 Mar 2022 00:11:49 +0100 Subject: Add test for reblog race condition fix (#17732) Follow-up to #17693 --- spec/services/reblog_service_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'spec/services') diff --git a/spec/services/reblog_service_spec.rb b/spec/services/reblog_service_spec.rb index e2077f282..c0ae5eedc 100644 --- a/spec/services/reblog_service_spec.rb +++ b/spec/services/reblog_service_spec.rb @@ -32,6 +32,18 @@ RSpec.describe ReblogService, type: :service do end end + context 'when the reblogged status is discarded in the meantime' do + let(:status) { Fabricate(:status, account: alice, visibility: :public) } + + before do + status.discard + end + + it 'raises an exception' do + expect { subject.call(alice, status) }.to raise_error ActiveRecord::ActiveRecordError + end + end + context 'ActivityPub' do let(:bob) { Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') } let(:status) { Fabricate(:status, account: bob) } -- cgit From ddbe906c25fc370c92fa557d3637d50b7af97754 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 12 Mar 2022 09:11:36 +0100 Subject: Fix not updating a status when newer version is fetched manually (#17745) --- app/helpers/jsonld_helper.rb | 8 ++++ app/lib/activitypub/activity.rb | 10 +---- app/lib/activitypub/activity/update.rb | 2 +- .../activitypub/fetch_remote_status_service.rb | 30 +++++++++----- spec/rails_helper.rb | 4 +- .../fetch_remote_status_service_spec.rb | 48 +++++++++++++++++++--- 6 files changed, 72 insertions(+), 30 deletions(-) (limited to 'spec/services') diff --git a/app/helpers/jsonld_helper.rb b/app/helpers/jsonld_helper.rb index ef16eef08..102e4b132 100644 --- a/app/helpers/jsonld_helper.rb +++ b/app/helpers/jsonld_helper.rb @@ -15,6 +15,14 @@ module JsonLdHelper value.is_a?(Array) ? value.first : value end + def uri_from_bearcap(str) + if str&.start_with?('bear:') + Addressable::URI.parse(str).query_values['u'] + else + str + end + end + # The url attribute can be a string, an array of strings, or an array of objects. # The objects could include a mimeType. Not-included mimeType means it's text/html. def url_to_href(value, preferred_type = nil) diff --git a/app/lib/activitypub/activity.rb b/app/lib/activitypub/activity.rb index 706960f92..f599e1b58 100644 --- a/app/lib/activitypub/activity.rb +++ b/app/lib/activitypub/activity.rb @@ -71,15 +71,7 @@ class ActivityPub::Activity end def object_uri - @object_uri ||= begin - str = value_or_id(@object) - - if str&.start_with?('bear:') - Addressable::URI.parse(str).query_values['u'] - else - str - end - end + @object_uri ||= uri_from_bearcap(value_or_id(@object)) end def unsupported_object_type? diff --git a/app/lib/activitypub/activity/update.rb b/app/lib/activitypub/activity/update.rb index 36ad5f446..5802ead5d 100644 --- a/app/lib/activitypub/activity/update.rb +++ b/app/lib/activitypub/activity/update.rb @@ -20,7 +20,7 @@ class ActivityPub::Activity::Update < ActivityPub::Activity end def update_status - return reject_payload! if invalid_origin?(@object['id']) + return reject_payload! if invalid_origin?(object_uri) @status = Status.find_by(uri: object_uri, account_id: @account.id) diff --git a/app/services/activitypub/fetch_remote_status_service.rb b/app/services/activitypub/fetch_remote_status_service.rb index 4f789d50b..9672b3d2b 100644 --- a/app/services/activitypub/fetch_remote_status_service.rb +++ b/app/services/activitypub/fetch_remote_status_service.rb @@ -15,24 +15,30 @@ class ActivityPub::FetchRemoteStatusService < BaseService return unless supported_context? - actor_id = nil + actor_uri = nil activity_json = nil + object_uri = nil if expected_object_type? - actor_id = value_or_id(first_of_value(@json['attributedTo'])) - activity_json = { 'type' => 'Create', 'actor' => actor_id, 'object' => @json } + actor_uri = value_or_id(first_of_value(@json['attributedTo'])) + activity_json = { 'type' => 'Create', 'actor' => actor_uri, 'object' => @json } + object_uri = uri_from_bearcap(@json['id']) elsif expected_activity_type? - actor_id = value_or_id(first_of_value(@json['actor'])) + actor_uri = value_or_id(first_of_value(@json['actor'])) activity_json = @json + object_uri = uri_from_bearcap(value_or_id(@json['object'])) end - return if activity_json.nil? || !trustworthy_attribution?(@json['id'], actor_id) + return if activity_json.nil? || object_uri.nil? || !trustworthy_attribution?(@json['id'], actor_uri) - actor = ActivityPub::TagManager.instance.uri_to_resource(actor_id, Account) - actor = ActivityPub::FetchRemoteAccountService.new.call(actor_id, id: true) if actor.nil? || needs_update?(actor) + actor = account_from_uri(actor_uri) return if actor.nil? || actor.suspended? + # If we fetched a status that already exists, then we need to treat the + # activity as an update rather than create + activity_json['type'] = 'Update' if equals_or_includes_any?(activity_json['type'], %w(Create)) && Status.where(uri: object_uri, account_id: actor.id).exists? + ActivityPub::Activity.factory(activity_json, actor).perform end @@ -43,6 +49,12 @@ class ActivityPub::FetchRemoteStatusService < BaseService Addressable::URI.parse(uri).normalized_host.casecmp(Addressable::URI.parse(attributed_to).normalized_host).zero? end + def account_from_uri(uri) + actor = ActivityPub::TagManager.instance.uri_to_resource(uri, Account) + actor = ActivityPub::FetchRemoteAccountService.new.call(uri, id: true) if actor.nil? || actor.possibly_stale? + actor + end + def supported_context? super(@json) end @@ -54,8 +66,4 @@ class ActivityPub::FetchRemoteStatusService < BaseService def expected_object_type? equals_or_includes_any?(@json['type'], ActivityPub::Activity::Create::SUPPORTED_TYPES + ActivityPub::Activity::Create::CONVERTED_TYPES) end - - def needs_update?(actor) - actor.possibly_stale? - end end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 86c2a9c52..217a8f2f8 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -60,9 +60,7 @@ RSpec.configure do |config| config.after :each do Rails.cache.clear - - keys = Redis.current.keys - Redis.current.del(keys) if keys.any? + Redis.current.del(Redis.current.keys) end end diff --git a/spec/services/activitypub/fetch_remote_status_service_spec.rb b/spec/services/activitypub/fetch_remote_status_service_spec.rb index 94574aa7f..68816e554 100644 --- a/spec/services/activitypub/fetch_remote_status_service_spec.rb +++ b/spec/services/activitypub/fetch_remote_status_service_spec.rb @@ -3,9 +3,11 @@ require 'rails_helper' RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do include ActionView::Helpers::TextHelper - let(:sender) { Fabricate(:account) } - let(:recipient) { Fabricate(:account) } - let(:valid_domain) { Rails.configuration.x.local_domain } + let!(:sender) { Fabricate(:account).tap { |account| account.update(uri: ActivityPub::TagManager.instance.uri_for(account)) } } + let!(:recipient) { Fabricate(:account) } + let!(:valid_domain) { Rails.configuration.x.local_domain } + + let(:existing_status) { nil } let(:note) do { @@ -19,11 +21,13 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do subject { described_class.new } + before do + stub_request(:head, 'https://example.com/watch?v=12345').to_return(status: 404, body: '') + end + describe '#call' do before do - sender.update(uri: ActivityPub::TagManager.instance.uri_for(sender)) - - stub_request(:head, 'https://example.com/watch?v=12345').to_return(status: 404, body: '') + existing_status subject.call(object[:id], prefetched_body: Oj.dump(object)) end @@ -186,5 +190,37 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do expect(sender.statuses.first).to be_nil end end + + context 'when status already exists' do + let(:existing_status) { Fabricate(:status, account: sender, text: 'Foo', uri: note[:id]) } + + context 'with a Note object' do + let(:object) { note } + + it 'updates status' do + existing_status.reload + expect(existing_status.text).to eq 'Lorem ipsum' + expect(existing_status.edits).to_not be_empty + end + end + + context 'with a Create activity' do + let(:object) do + { + '@context': 'https://www.w3.org/ns/activitystreams', + id: "https://#{valid_domain}/@foo/1234/create", + type: 'Create', + actor: ActivityPub::TagManager.instance.uri_for(sender), + object: note, + } + end + + it 'updates status' do + existing_status.reload + expect(existing_status.text).to eq 'Lorem ipsum' + expect(existing_status.edits).to_not be_empty + end + end + end end end -- cgit From 92a86b958ee7b96dbcbc17237dfcb1af0f15740c Mon Sep 17 00:00:00 2001 From: Claire Date: Sat, 12 Mar 2022 19:33:10 +0100 Subject: Fix issues with processing toot edits (#17748) * Fix searching for an already-known status by URL not working * Fix Update processing from statuses prior to 20220302232632 `ordered_media_attachment_ids_changed?` would return `true` when going from `nil` to anything (including `[]`). * Add tests --- .../activitypub/process_status_update_service.rb | 11 +++++++---- .../process_status_update_service_spec.rb | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) (limited to 'spec/services') diff --git a/app/services/activitypub/process_status_update_service.rb b/app/services/activitypub/process_status_update_service.rb index 70e9cb7d9..47a788c30 100644 --- a/app/services/activitypub/process_status_update_service.rb +++ b/app/services/activitypub/process_status_update_service.rb @@ -13,7 +13,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService @poll_changed = false # Only native types can be updated at the moment - return if !expected_type? || already_updated_more_recently? + return @status if !expected_type? || already_updated_more_recently? last_edit_date = status.edited_at.presence || status.created_at @@ -41,13 +41,16 @@ class ActivityPub::ProcessStatusUpdateService < BaseService end forward_activity! if significant_changes? && @status_parser.edited_at.present? && @status_parser.edited_at > last_edit_date + + @status end private def update_media_attachments! - previous_media_attachments = @status.media_attachments.to_a - next_media_attachments = [] + previous_media_attachments = @status.media_attachments.to_a + previous_media_attachments_ids = @status.ordered_media_attachment_ids || previous_media_attachments.map(&:id) + next_media_attachments = [] as_array(@json['attachment']).each do |attachment| media_attachment_parser = ActivityPub::Parser::MediaAttachmentParser.new(attachment) @@ -87,7 +90,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService @status.ordered_media_attachment_ids = next_media_attachments.map(&:id) @status.media_attachments.reload - @media_attachments_changed = true if @status.ordered_media_attachment_ids_changed? + @media_attachments_changed = true if @status.ordered_media_attachment_ids != previous_media_attachments_ids end def update_poll! diff --git a/spec/services/activitypub/process_status_update_service_spec.rb b/spec/services/activitypub/process_status_update_service_spec.rb index 40b405217..788c7c9d9 100644 --- a/spec/services/activitypub/process_status_update_service_spec.rb +++ b/spec/services/activitypub/process_status_update_service_spec.rb @@ -46,6 +46,26 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do expect(status.reload.spoiler_text).to eq 'Show more' end + context 'with no changes and originally with no ordered_media_attachment_ids' do + let(:payload) do + { + '@context': 'https://www.w3.org/ns/activitystreams', + id: 'foo', + type: 'Note', + content: 'Hello world', + } + end + + before do + status.update(ordered_media_attachment_ids: nil) + subject.call(status, json) + end + + it 'does not record an update' do + expect(status.reload.edited?).to be false + end + end + context 'originally without tags' do before do subject.call(status, json) -- cgit