Skip to content

Commit

Permalink
Fix: ブーストが1つでもあるとバックアップ時にエラーが出る問題 (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode authored Oct 21, 2023
1 parent 63f0f1b commit a87f6f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/services/concerns/payloadable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ def serialize_payload(record, serializer, options = {})
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
Expand Down
11 changes: 10 additions & 1 deletion spec/services/backup_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
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)
Expand Down Expand Up @@ -60,10 +61,11 @@ def expect_outbox_export
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

Expand Down Expand Up @@ -98,4 +100,11 @@ def include_create_item(status)
}),
})
end

def include_announce_item(status)
include({
'type' => 'Announce',
'object' => ActivityPub::TagManager.instance.uri_for(status.reblog),
})
end
end

0 comments on commit a87f6f4

Please sign in to comment.