From 709c6685a90bb819696566cc9e42e587546d72dc Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 22 Feb 2016 16:00:20 +0100 Subject: Made some progress --- app/api/mastodon/entities.rb | 2 ++ app/api/mastodon/ostatus.rb | 15 +++++++-------- app/api/mastodon/rest.rb | 25 +++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 8 deletions(-) (limited to 'app/api') diff --git a/app/api/mastodon/entities.rb b/app/api/mastodon/entities.rb index a3f40ec48..2e56a67df 100644 --- a/app/api/mastodon/entities.rb +++ b/app/api/mastodon/entities.rb @@ -3,6 +3,8 @@ module Mastodon class Account < Grape::Entity expose :username expose :domain + expose :display_name + expose :note end class Status < Grape::Entity diff --git a/app/api/mastodon/ostatus.rb b/app/api/mastodon/ostatus.rb index fcde980f7..4676bc429 100644 --- a/app/api/mastodon/ostatus.rb +++ b/app/api/mastodon/ostatus.rb @@ -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 diff --git a/app/api/mastodon/rest.rb b/app/api/mastodon/rest.rb index e011ab34d..eaf337938 100644 --- a/app/api/mastodon/rest.rb +++ b/app/api/mastodon/rest.rb @@ -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 -- cgit