Skip to content

Commit

Permalink
Fix duplicate @context attribute in user export (mastodon#30653)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire authored and Ember-ruby committed Jul 5, 2024
1 parent cc6cbe1 commit a2d5543
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/services/backup_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def call(backup)

def build_outbox_json!(file)
skeleton = serialize(collection_presenter, ActivityPub::CollectionSerializer)
skeleton[:@context] = full_context
skeleton[:orderedItems] = ['!PLACEHOLDER!']
skeleton['@context'] = full_context
skeleton['orderedItems'] = ['!PLACEHOLDER!']
skeleton = Oj.dump(skeleton)
prepend, append = skeleton.split('"!PLACEHOLDER!"')
add_comma = false
Expand Down
10 changes: 8 additions & 2 deletions spec/services/backup_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ def process_backup
end

def expect_outbox_export
json = export_json(:outbox)
body = export_json_raw(:outbox)
json = Oj.load(body)

aggregate_failures do
expect(body.scan('@context').count).to eq 1
expect(json['@context']).to_not be_nil
expect(json['type']).to eq 'OrderedCollection'
expect(json['totalItems']).to eq 2
Expand Down Expand Up @@ -85,8 +87,12 @@ def expect_bookmarks_export
end
end

def export_json_raw(type)
read_zip_file(backup, "#{type}.json")
end

def export_json(type)
Oj.load(read_zip_file(backup, "#{type}.json"))
Oj.load(export_json_raw(type))
end

def include_create_item(status)
Expand Down

0 comments on commit a2d5543

Please sign in to comment.