Fix duplicate orderedItems
in user archive's outbox.json
(#31099)
This commit is contained in:
parent
161aa0f8f6
commit
13bab94265
4 changed files with 10 additions and 9 deletions
|
@ -20,6 +20,6 @@ class ActivityPub::Adapter < ActiveModelSerializers::Adapter::Base
|
||||||
serialized_hash = serialized_hash.select { |k, _| options[:fields].include?(k) } if options[:fields]
|
serialized_hash = serialized_hash.select { |k, _| options[:fields].include?(k) } if options[:fields]
|
||||||
serialized_hash = self.class.transform_key_casing!(serialized_hash, instance_options)
|
serialized_hash = self.class.transform_key_casing!(serialized_hash, instance_options)
|
||||||
|
|
||||||
{ '@context' => serialized_context(named_contexts, context_extensions) }.merge(serialized_hash)
|
{ '@context': serialized_context(named_contexts, context_extensions) }.merge(serialized_hash)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,8 +19,8 @@ class BackupService < BaseService
|
||||||
|
|
||||||
def build_outbox_json!(file)
|
def build_outbox_json!(file)
|
||||||
skeleton = serialize(collection_presenter, ActivityPub::CollectionSerializer)
|
skeleton = serialize(collection_presenter, ActivityPub::CollectionSerializer)
|
||||||
skeleton['@context'] = full_context
|
skeleton[:@context] = full_context
|
||||||
skeleton['orderedItems'] = ['!PLACEHOLDER!']
|
skeleton[:orderedItems] = ['!PLACEHOLDER!']
|
||||||
skeleton = Oj.dump(skeleton)
|
skeleton = Oj.dump(skeleton)
|
||||||
prepend, append = skeleton.split('"!PLACEHOLDER!"')
|
prepend, append = skeleton.split('"!PLACEHOLDER!"')
|
||||||
add_comma = false
|
add_comma = false
|
||||||
|
@ -33,7 +33,7 @@ class BackupService < BaseService
|
||||||
|
|
||||||
file.write(statuses.map do |status|
|
file.write(statuses.map do |status|
|
||||||
item = serialize_payload(ActivityPub::ActivityPresenter.from_status(status), ActivityPub::ActivitySerializer)
|
item = serialize_payload(ActivityPub::ActivityPresenter.from_status(status), ActivityPub::ActivitySerializer)
|
||||||
item.delete('@context')
|
item.delete(:@context)
|
||||||
|
|
||||||
unless item[:type] == 'Announce' || item[:object][:attachment].blank?
|
unless item[:type] == 'Announce' || item[:object][:attachment].blank?
|
||||||
item[:object][:attachment].each do |attachment|
|
item[:object][:attachment].each do |attachment|
|
||||||
|
|
|
@ -59,7 +59,7 @@ RSpec.describe ActivityPub::Adapter do
|
||||||
let(:serializer_class) { TestWithBasicContextSerializer }
|
let(:serializer_class) { TestWithBasicContextSerializer }
|
||||||
|
|
||||||
it 'renders a basic @context' do
|
it 'renders a basic @context' do
|
||||||
expect(subject).to include({ '@context' => 'https://www.w3.org/ns/activitystreams' })
|
expect(subject).to include({ '@context': 'https://www.w3.org/ns/activitystreams' })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ RSpec.describe ActivityPub::Adapter do
|
||||||
let(:serializer_class) { TestWithNamedContextSerializer }
|
let(:serializer_class) { TestWithNamedContextSerializer }
|
||||||
|
|
||||||
it 'renders a @context with both items' do
|
it 'renders a @context with both items' do
|
||||||
expect(subject).to include({ '@context' => ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1'] })
|
expect(subject).to include({ '@context': ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1'] })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ RSpec.describe ActivityPub::Adapter do
|
||||||
let(:serializer_class) { TestWithNestedNamedContextSerializer }
|
let(:serializer_class) { TestWithNestedNamedContextSerializer }
|
||||||
|
|
||||||
it 'renders a @context with both items' do
|
it 'renders a @context with both items' do
|
||||||
expect(subject).to include({ '@context' => ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1'] })
|
expect(subject).to include({ '@context': ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1'] })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ RSpec.describe ActivityPub::Adapter do
|
||||||
let(:serializer_class) { TestWithContextExtensionSerializer }
|
let(:serializer_class) { TestWithContextExtensionSerializer }
|
||||||
|
|
||||||
it 'renders a @context with the extension' do
|
it 'renders a @context with the extension' do
|
||||||
expect(subject).to include({ '@context' => ['https://www.w3.org/ns/activitystreams', { 'sensitive' => 'as:sensitive' }] })
|
expect(subject).to include({ '@context': ['https://www.w3.org/ns/activitystreams', { 'sensitive' => 'as:sensitive' }] })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ RSpec.describe ActivityPub::Adapter do
|
||||||
let(:serializer_class) { TestWithNestedContextExtensionSerializer }
|
let(:serializer_class) { TestWithNestedContextExtensionSerializer }
|
||||||
|
|
||||||
it 'renders a @context with both extensions' do
|
it 'renders a @context with both extensions' do
|
||||||
expect(subject).to include({ '@context' => ['https://www.w3.org/ns/activitystreams', { 'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers', 'sensitive' => 'as:sensitive' }] })
|
expect(subject).to include({ '@context': ['https://www.w3.org/ns/activitystreams', { 'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers', 'sensitive' => 'as:sensitive' }] })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -60,6 +60,7 @@ RSpec.describe BackupService, type: :service do
|
||||||
|
|
||||||
aggregate_failures do
|
aggregate_failures do
|
||||||
expect(body.scan('@context').count).to eq 1
|
expect(body.scan('@context').count).to eq 1
|
||||||
|
expect(body.scan('orderedItems').count).to eq 1
|
||||||
expect(json['@context']).to_not be_nil
|
expect(json['@context']).to_not be_nil
|
||||||
expect(json['type']).to eq 'OrderedCollection'
|
expect(json['type']).to eq 'OrderedCollection'
|
||||||
expect(json['totalItems']).to eq 2
|
expect(json['totalItems']).to eq 2
|
||||||
|
|
Loading…
Reference in a new issue