Use JSON.generate in backup service (#38234)
This commit is contained in:
@@ -23,7 +23,7 @@ class BackupService < BaseService
|
|||||||
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 = JSON.generate(skeleton)
|
||||||
prepend, append = skeleton.split('"!PLACEHOLDER!"')
|
prepend, append = skeleton.split('"!PLACEHOLDER!"')
|
||||||
add_comma = false
|
add_comma = false
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ class BackupService < BaseService
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Oj.dump(item)
|
JSON.generate(item)
|
||||||
end.join(','))
|
end.join(','))
|
||||||
|
|
||||||
GC.start
|
GC.start
|
||||||
@@ -107,7 +107,7 @@ class BackupService < BaseService
|
|||||||
download_to_zip(zipfile, account.avatar, "avatar#{File.extname(account.avatar.path)}") if account.avatar.exists?
|
download_to_zip(zipfile, account.avatar, "avatar#{File.extname(account.avatar.path)}") if account.avatar.exists?
|
||||||
download_to_zip(zipfile, account.header, "header#{File.extname(account.header.path)}") if account.header.exists?
|
download_to_zip(zipfile, account.header, "header#{File.extname(account.header.path)}") if account.header.exists?
|
||||||
|
|
||||||
json = Oj.dump(actor)
|
json = JSON.generate(actor)
|
||||||
|
|
||||||
zipfile.get_output_stream('actor.json') do |io|
|
zipfile.get_output_stream('actor.json') do |io|
|
||||||
io.write(json)
|
io.write(json)
|
||||||
@@ -118,7 +118,7 @@ class BackupService < BaseService
|
|||||||
skeleton = serialize(ActivityPub::CollectionPresenter.new(id: 'likes.json', type: :ordered, size: 0, items: []), ActivityPub::CollectionSerializer)
|
skeleton = serialize(ActivityPub::CollectionPresenter.new(id: 'likes.json', type: :ordered, size: 0, items: []), ActivityPub::CollectionSerializer)
|
||||||
skeleton.delete(:totalItems)
|
skeleton.delete(:totalItems)
|
||||||
skeleton[:orderedItems] = ['!PLACEHOLDER!']
|
skeleton[:orderedItems] = ['!PLACEHOLDER!']
|
||||||
skeleton = Oj.dump(skeleton)
|
skeleton = JSON.generate(skeleton)
|
||||||
prepend, append = skeleton.split('"!PLACEHOLDER!"')
|
prepend, append = skeleton.split('"!PLACEHOLDER!"')
|
||||||
|
|
||||||
zipfile.get_output_stream('likes.json') do |io|
|
zipfile.get_output_stream('likes.json') do |io|
|
||||||
@@ -131,7 +131,7 @@ class BackupService < BaseService
|
|||||||
add_comma = true
|
add_comma = true
|
||||||
|
|
||||||
io.write(statuses.map do |status|
|
io.write(statuses.map do |status|
|
||||||
Oj.dump(ActivityPub::TagManager.instance.uri_for(status))
|
JSON.generate(ActivityPub::TagManager.instance.uri_for(status))
|
||||||
end.join(','))
|
end.join(','))
|
||||||
|
|
||||||
GC.start
|
GC.start
|
||||||
@@ -145,7 +145,7 @@ class BackupService < BaseService
|
|||||||
skeleton = serialize(ActivityPub::CollectionPresenter.new(id: 'bookmarks.json', type: :ordered, size: 0, items: []), ActivityPub::CollectionSerializer)
|
skeleton = serialize(ActivityPub::CollectionPresenter.new(id: 'bookmarks.json', type: :ordered, size: 0, items: []), ActivityPub::CollectionSerializer)
|
||||||
skeleton.delete(:totalItems)
|
skeleton.delete(:totalItems)
|
||||||
skeleton[:orderedItems] = ['!PLACEHOLDER!']
|
skeleton[:orderedItems] = ['!PLACEHOLDER!']
|
||||||
skeleton = Oj.dump(skeleton)
|
skeleton = JSON.generate(skeleton)
|
||||||
prepend, append = skeleton.split('"!PLACEHOLDER!"')
|
prepend, append = skeleton.split('"!PLACEHOLDER!"')
|
||||||
|
|
||||||
zipfile.get_output_stream('bookmarks.json') do |io|
|
zipfile.get_output_stream('bookmarks.json') do |io|
|
||||||
@@ -157,7 +157,7 @@ class BackupService < BaseService
|
|||||||
add_comma = true
|
add_comma = true
|
||||||
|
|
||||||
io.write(statuses.map do |status|
|
io.write(statuses.map do |status|
|
||||||
Oj.dump(ActivityPub::TagManager.instance.uri_for(status))
|
JSON.generate(ActivityPub::TagManager.instance.uri_for(status))
|
||||||
end.join(','))
|
end.join(','))
|
||||||
|
|
||||||
GC.start
|
GC.start
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ RSpec.describe BackupService do
|
|||||||
|
|
||||||
def expect_outbox_export
|
def expect_outbox_export
|
||||||
body = export_json_raw(:outbox)
|
body = export_json_raw(:outbox)
|
||||||
json = Oj.load(body)
|
json = JSON.parse(body)
|
||||||
|
|
||||||
aggregate_failures do
|
aggregate_failures do
|
||||||
expect(body.scan('@context').count).to eq 1
|
expect(body.scan('@context').count).to eq 1
|
||||||
@@ -93,7 +93,7 @@ RSpec.describe BackupService do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def export_json(type)
|
def export_json(type)
|
||||||
Oj.load(export_json_raw(type))
|
JSON.parse(export_json_raw(type))
|
||||||
end
|
end
|
||||||
|
|
||||||
def include_create_item(status)
|
def include_create_item(status)
|
||||||
|
|||||||
Reference in New Issue
Block a user