Fix: ブーストが1つでもあるとバックアップ時にエラーが出る問題 (#153)
This commit is contained in:
parent
63f0f1bfd0
commit
a87f6f4828
2 changed files with 12 additions and 2 deletions
|
@ -16,8 +16,9 @@ module Payloadable
|
|||
always_sign = options.delete(:always_sign)
|
||||
payload = ActiveModelSerializers::SerializableResource.new(record, options.merge(serializer: serializer, adapter: ActivityPub::Adapter)).as_json
|
||||
object = record.respond_to?(:virtual_object) ? record.virtual_object : record
|
||||
bearcap = object.is_a?(String) && record.respond_to?(:type) && (record.type == 'Create' || record.type == 'Update')
|
||||
|
||||
if ((object.respond_to?(:sign?) && object.sign?) && signer && (always_sign || signing_enabled?)) || object.is_a?(String)
|
||||
if ((object.respond_to?(:sign?) && object.sign?) && signer && (always_sign || signing_enabled?)) || bearcap
|
||||
ActivityPub::LinkedDataSignature.new(payload).sign!(signer, sign_with: sign_with)
|
||||
else
|
||||
payload
|
||||
|
|
|
@ -11,6 +11,7 @@ RSpec.describe BackupService, type: :service do
|
|||
let!(:private_status) { Fabricate(:status, account: user.account, text: 'secret', visibility: :private) }
|
||||
let!(:favourite) { Fabricate(:favourite, account: user.account) }
|
||||
let!(:bookmark) { Fabricate(:bookmark, account: user.account) }
|
||||
let!(:reblog) { Fabricate(:status, account: user.account, reblog_of_id: Fabricate(:status).id) }
|
||||
let!(:backup) { Fabricate(:backup, user: user) }
|
||||
|
||||
def read_zip_file(backup, filename)
|
||||
|
@ -60,10 +61,11 @@ RSpec.describe BackupService, type: :service do
|
|||
aggregate_failures do
|
||||
expect(json['@context']).to_not be_nil
|
||||
expect(json['type']).to eq 'OrderedCollection'
|
||||
expect(json['totalItems']).to eq 2
|
||||
expect(json['totalItems']).to eq 3
|
||||
expect(json['orderedItems'][0]['@context']).to be_nil
|
||||
expect(json['orderedItems'][0]).to include_create_item(status)
|
||||
expect(json['orderedItems'][1]).to include_create_item(private_status)
|
||||
expect(json['orderedItems'][2]).to include_announce_item(reblog)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -98,4 +100,11 @@ RSpec.describe BackupService, type: :service do
|
|||
}),
|
||||
})
|
||||
end
|
||||
|
||||
def include_announce_item(status)
|
||||
include({
|
||||
'type' => 'Announce',
|
||||
'object' => ActivityPub::TagManager.instance.uri_for(status.reblog),
|
||||
})
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue