Browse Source

Set correct content-type for ActivityPub JSON (#4592)

pull/4/head
Eugen Rochko 7 years ago
committed by GitHub
parent
commit
6df8bd277b
9 changed files with 16 additions and 8 deletions
  1. +1
    -1
      app/controllers/accounts_controller.rb
  2. +1
    -1
      app/controllers/activitypub/outboxes_controller.rb
  3. +1
    -1
      app/controllers/follower_accounts_controller.rb
  4. +1
    -1
      app/controllers/following_accounts_controller.rb
  5. +2
    -2
      app/controllers/statuses_controller.rb
  6. +1
    -1
      app/controllers/tags_controller.rb
  7. +1
    -1
      config/initializers/mime_types.rb
  8. +4
    -0
      spec/controllers/accounts_controller_spec.rb
  9. +4
    -0
      spec/controllers/activitypub/outboxes_controller_spec.rb

+ 1
- 1
app/controllers/accounts_controller.rb View File

@ -17,7 +17,7 @@ class AccountsController < ApplicationController
end
format.json do
render json: @account, serializer: ActivityPub::ActorSerializer, adapter: ActivityPub::Adapter
render json: @account, serializer: ActivityPub::ActorSerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json'
end
end
end

+ 1
- 1
app/controllers/activitypub/outboxes_controller.rb View File

@ -7,7 +7,7 @@ class ActivityPub::OutboxesController < Api::BaseController
@statuses = @account.statuses.permitted_for(@account, current_account).paginate_by_max_id(20, params[:max_id], params[:since_id])
@statuses = cache_collection(@statuses, Status)
render json: outbox_presenter, serializer: ActivityPub::CollectionSerializer, adapter: ActivityPub::Adapter
render json: outbox_presenter, serializer: ActivityPub::CollectionSerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json'
end
private

+ 1
- 1
app/controllers/follower_accounts_controller.rb View File

@ -10,7 +10,7 @@ class FollowerAccountsController < ApplicationController
format.html
format.json do
render json: collection_presenter, serializer: ActivityPub::CollectionSerializer, adapter: ActivityPub::Adapter
render json: collection_presenter, serializer: ActivityPub::CollectionSerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json'
end
end
end

+ 1
- 1
app/controllers/following_accounts_controller.rb View File

@ -10,7 +10,7 @@ class FollowingAccountsController < ApplicationController
format.html
format.json do
render json: collection_presenter, serializer: ActivityPub::CollectionSerializer, adapter: ActivityPub::Adapter
render json: collection_presenter, serializer: ActivityPub::CollectionSerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json'
end
end
end

+ 2
- 2
app/controllers/statuses_controller.rb View File

@ -20,13 +20,13 @@ class StatusesController < ApplicationController
end
format.json do
render json: @status, serializer: ActivityPub::NoteSerializer, adapter: ActivityPub::Adapter
render json: @status, serializer: ActivityPub::NoteSerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json'
end
end
end
def activity
render json: @status, serializer: ActivityPub::ActivitySerializer, adapter: ActivityPub::Adapter
render json: @status, serializer: ActivityPub::ActivitySerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json'
end
private

+ 1
- 1
app/controllers/tags_controller.rb View File

@ -12,7 +12,7 @@ class TagsController < ApplicationController
format.html
format.json do
render json: collection_presenter, serializer: ActivityPub::CollectionSerializer, adapter: ActivityPub::Adapter
render json: collection_presenter, serializer: ActivityPub::CollectionSerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json'
end
end
end

+ 1
- 1
config/initializers/mime_types.rb View File

@ -1,4 +1,4 @@
# Be sure to restart your server when you modify this file.
Mime::Type.register 'application/json', :json, %w(text/x-json application/jsonrequest application/jrd+json application/activity+json)
Mime::Type.register 'application/json', :json, %w(text/x-json application/jsonrequest application/jrd+json application/activity+json application/ld+json)
Mime::Type.register 'text/xml', :xml, %w(application/xml application/atom+xml application/xrd+xml)

+ 4
- 0
spec/controllers/accounts_controller_spec.rb View File

@ -48,6 +48,10 @@ RSpec.describe AccountsController, type: :controller do
it 'returns http success with Activity Streams 2.0' do
expect(response).to have_http_status(:success)
end
it 'returns application/activity+json' do
expect(response.content_type).to eq 'application/activity+json'
end
end
context 'html' do

+ 4
- 0
spec/controllers/activitypub/outboxes_controller_spec.rb View File

@ -15,5 +15,9 @@ RSpec.describe ActivityPub::OutboxesController, type: :controller do
it 'returns http success' do
expect(response).to have_http_status(:success)
end
it 'returns application/activity+json' do
expect(response.content_type).to eq 'application/activity+json'
end
end
end

Loading…
Cancel
Save