Browse Source

Merge pull request #603 from evanminto/activitypub-account

Expose ActivityStreams 2.0 representation of accounts
master
Eugen 7 years ago
committed by GitHub
parent
commit
9d5fb49cd8
7 changed files with 30 additions and 2 deletions
  1. +2
    -0
      app/controllers/accounts_controller.rb
  2. +8
    -0
      app/views/accounts/show.activitystreams2.rabl
  3. +1
    -0
      app/views/activitypub/base.activitystreams2.rabl
  4. +3
    -0
      app/views/activitypub/intransient.activitystreams2.rabl
  5. +3
    -0
      app/views/activitypub/types/person.activitystreams2.rabl
  6. +3
    -2
      config/initializers/mime_types.rb
  7. +10
    -0
      spec/controllers/accounts_controller_spec.rb

+ 2
- 0
app/controllers/accounts_controller.rb View File

@ -18,6 +18,8 @@ class AccountsController < ApplicationController
format.atom do
@entries = @account.stream_entries.order('id desc').where(hidden: false).with_includes.paginate_by_max_id(20, params[:max_id], params[:since_id])
end
format.activitystreams2
end
end

+ 8
- 0
app/views/accounts/show.activitystreams2.rabl View File

@ -0,0 +1,8 @@
extends 'activitypub/types/person.activitystreams2.rabl'
object @account
attributes display_name: :name, username: :preferredUsername, note: :summary
node(:icon) { |account| full_asset_url(account.avatar.url(:original)) }
node(:image) { |account| full_asset_url(account.header.url(:original)) }

+ 1
- 0
app/views/activitypub/base.activitystreams2.rabl View File

@ -0,0 +1 @@
node(:'@context') { 'https://www.w3.org/ns/activitystreams' }

+ 3
- 0
app/views/activitypub/intransient.activitystreams2.rabl View File

@ -0,0 +1,3 @@
extends 'activitypub/base.activitystreams2.rabl'
node(:id) { request.original_url }

+ 3
- 0
app/views/activitypub/types/person.activitystreams2.rabl View File

@ -0,0 +1,3 @@
extends 'activitypub/intransient.activitystreams2.rabl'
node(:type) { 'Person' }

+ 3
- 2
config/initializers/mime_types.rb View File

@ -1,4 +1,5 @@
# 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 )
Mime::Type.register "text/xml", :xml, %w( application/xml application/atom+xml application/xrd+xml )
Mime::Type.register "application/json", :json, %w( text/x-json application/jsonrequest application/jrd+json )
Mime::Type.register "text/xml", :xml, %w( application/xml application/atom+xml application/xrd+xml )
Mime::Type.register "application/activity+json", :activitystreams2

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

@ -24,6 +24,16 @@ RSpec.describe AccountsController, type: :controller do
end
end
context 'activitystreams2' do
before do
get :show, params: { username: alice.username }, format: 'activitystreams2'
end
it 'returns http success with Activity Streams 2.0' do
expect(response).to have_http_status(:success)
end
end
context 'html' do
before do
get :show, params: { username: alice.username }

Loading…
Cancel
Save