about summary refs log tree commit diff
path: root/app/api
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-02-22 16:00:20 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-02-22 16:00:20 +0100
commit709c6685a90bb819696566cc9e42e587546d72dc (patch)
tree272783009e0a0c8b13b8003dc4bc4e58f3b0b84b /app/api
parent9c4856bdb11fc9311ab30a97224cee3dfaec492f (diff)
Made some progress
Diffstat (limited to 'app/api')
-rw-r--r--app/api/mastodon/entities.rb2
-rw-r--r--app/api/mastodon/ostatus.rb15
-rw-r--r--app/api/mastodon/rest.rb25
3 files changed, 34 insertions, 8 deletions
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