Made some progress

This commit is contained in:
Eugen Rochko 2016-02-22 16:00:20 +01:00
parent 9c4856bdb1
commit 709c6685a9
61 changed files with 570 additions and 37 deletions

View file

@ -3,6 +3,8 @@ module Mastodon
class Account < Grape::Entity
expose :username
expose :domain
expose :display_name
expose :note
end
class Status < Grape::Entity

View file

@ -8,12 +8,10 @@ module Mastodon
resource :subscriptions do
helpers do
def subscription_url(account)
"https://649841dc.ngrok.io/api#{subscriptions_path(id: account.id)}"
end
include ApplicationHelper
end
desc 'Receive updates from a feed'
desc 'Receive updates from an account'
params do
requires :id, type: String, desc: 'Account ID'
@ -23,14 +21,14 @@ module Mastodon
body = request.body.read
if @account.subscription(subscription_url(@account)).verify(body, env['HTTP_X_HUB_SIGNATURE'])
ProcessFeedUpdateService.new.(body, @account)
ProcessFeedService.new.(body, @account)
status 201
else
status 202
end
end
desc 'Confirm PuSH subscription to a feed'
desc 'Confirm PuSH subscription to an account'
params do
requires :id, type: String, desc: 'Account ID'
@ -49,14 +47,15 @@ module Mastodon
end
resource :salmon do
desc 'Receive Salmon updates'
desc 'Receive Salmon updates targeted to account'
params do
requires :id, type: String, desc: 'Account ID'
end
post ':id' do
# todo
ProcessInteractionService.new.(request.body.read, @account)
status 201
end
end
end

View file

@ -5,9 +5,34 @@ module Mastodon
resource :statuses do
desc 'Return a public timeline'
get :all do
present Status.all, with: Mastodon::Entities::Status
end
desc 'Return the home timeline of a logged in user'
get :home do
# todo
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