1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00

API methods for retrieving home and mentions timelines

This commit is contained in:
Eugen Rochko 2016-03-07 13:25:26 +01:00
parent f099bc6091
commit fe57f6330f
5 changed files with 18 additions and 1 deletions

View file

@ -15,7 +15,7 @@ class Api::AccountsController < ApiController
end end
def statuses def statuses
@statuses = @account.statuses @statuses = @account.statuses.order('created_at desc')
end end
def follow def follow

View file

@ -20,4 +20,12 @@ class Api::StatusesController < ApiController
@status = FavouriteService.new.(current_user.account, Status.find(params[:id])).status @status = FavouriteService.new.(current_user.account, Status.find(params[:id])).status
render action: :show render action: :show
end end
def home
@statuses = Status.where(account: [current_user.account] + current_user.account.following).order('created_at desc')
end
def mentions
@statuses = Status.where(id: Mention.where(account: current_user.account).pluck(:status_id)).order('created_at desc')
end
end end

View file

@ -0,0 +1,2 @@
collection @statuses
extends('api/statuses/show')

View file

@ -0,0 +1,2 @@
collection @statuses
extends('api/statuses/show')

View file

@ -24,6 +24,11 @@ Rails.application.routes.draw do
# JSON / REST API # JSON / REST API
resources :statuses, only: [:create, :show] do resources :statuses, only: [:create, :show] do
collection do
get :home
get :mentions
end
member do member do
post :reblog post :reblog
post :favourite post :favourite