diff options
Diffstat (limited to 'app/api')
-rw-r--r-- | app/api/mastodon/api.rb | 8 | ||||
-rw-r--r-- | app/api/mastodon/entities.rb | 54 | ||||
-rw-r--r-- | app/api/mastodon/ostatus.rb | 62 | ||||
-rw-r--r-- | app/api/mastodon/rest.rb | 44 |
4 files changed, 0 insertions, 168 deletions
diff --git a/app/api/mastodon/api.rb b/app/api/mastodon/api.rb deleted file mode 100644 index 39469dc65..000000000 --- a/app/api/mastodon/api.rb +++ /dev/null @@ -1,8 +0,0 @@ -module Mastodon - class API < Grape::API - rescue_from :all - - mount Mastodon::Ostatus - mount Mastodon::Rest - end -end diff --git a/app/api/mastodon/entities.rb b/app/api/mastodon/entities.rb deleted file mode 100644 index 1c0e768f8..000000000 --- a/app/api/mastodon/entities.rb +++ /dev/null @@ -1,54 +0,0 @@ -module Mastodon - module Entities - class Account < Grape::Entity - include ApplicationHelper - - expose :id - expose :username - - expose :domain do |account| - account.local? ? LOCAL_DOMAIN : account.domain - end - - expose :display_name - expose :note - - expose :url do |account| - account.local? ? profile_url(name: account.username) : account.url - end - end - - class Status < Grape::Entity - include ApplicationHelper - - format_with(:iso_timestamp) { |dt| dt.iso8601 } - - expose :id - - expose :uri do |status| - status.local? ? unique_tag(status.stream_entry.created_at, status.stream_entry.activity_id, status.stream_entry.activity_type) : status.uri - end - - expose :url do |status| - status.local? ? status_url(name: status.account.username, id: status.id) : status.url - end - - expose :text - expose :in_reply_to_id - - expose :reblog_of_id - expose :reblog, using: Mastodon::Entities::Status - - expose :account, using: Mastodon::Entities::Account - - with_options(format_with: :iso_timestamp) do - expose :created_at - expose :updated_at - end - end - - class StreamEntry < Grape::Entity - expose :activity, using: Mastodon::Entities::Status - end - end -end diff --git a/app/api/mastodon/ostatus.rb b/app/api/mastodon/ostatus.rb deleted file mode 100644 index 4676bc429..000000000 --- a/app/api/mastodon/ostatus.rb +++ /dev/null @@ -1,62 +0,0 @@ -module Mastodon - class Ostatus < Grape::API - format :txt - - before do - @account = Account.find(params[:id]) - end - - resource :subscriptions do - helpers do - include ApplicationHelper - end - - desc 'Receive updates from an account' - - params do - requires :id, type: String, desc: 'Account ID' - end - - post ':id' do - body = request.body.read - - if @account.subscription(subscription_url(@account)).verify(body, env['HTTP_X_HUB_SIGNATURE']) - ProcessFeedService.new.(body, @account) - status 201 - else - status 202 - end - end - - desc 'Confirm PuSH subscription to an account' - - params do - requires :id, type: String, desc: 'Account ID' - requires 'hub.topic', type: String, desc: 'Topic URL' - requires 'hub.verify_token', type: String, desc: 'Verification token' - requires 'hub.challenge', type: String, desc: 'Hub challenge' - end - - get ':id' do - if @account.subscription(subscription_url(@account)).valid?(params['hub.topic'], params['hub.verify_token']) - params['hub.challenge'] - else - error! :not_found, 404 - end - end - end - - resource :salmon do - desc 'Receive Salmon updates targeted to account' - - params do - requires :id, type: String, desc: 'Account ID' - end - - post ':id' do - ProcessInteractionService.new.(request.body.read, @account) - status 201 - end - end - end -end diff --git a/app/api/mastodon/rest.rb b/app/api/mastodon/rest.rb deleted file mode 100644 index eb5232165..000000000 --- a/app/api/mastodon/rest.rb +++ /dev/null @@ -1,44 +0,0 @@ -module Mastodon - class Rest < Grape::API - version 'v1', using: :path - format :json - - helpers do - def current_user - User.first - end - end - - resource :timelines do - desc 'Return a public timeline' - - get :public do - # todo - end - - desc 'Return the home timeline of a logged in user' - - get :home do - present current_user.timeline, with: Mastodon::Entities::StreamEntry - end - - desc 'Return the notifications timeline of a logged in user' - - get :notifications do - # todo - end - end - - resource :accounts do - desc 'Return a user profile' - - params do - requires :id, type: String, desc: 'Account ID' - end - - get ':id' do - present Account.find(params[:id]), with: Mastodon::Entities::Account - end - end - end -end |