Skip to content
Snippets Groups Projects
Commit fe57f633 authored by Eugen Rochko's avatar Eugen Rochko
Browse files

API methods for retrieving home and mentions timelines

parent f099bc60
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,7 @@ class Api::AccountsController < ApiController
end
def statuses
@statuses = @account.statuses
@statuses = @account.statuses.order('created_at desc')
end
def follow
......
......@@ -20,4 +20,12 @@ class Api::StatusesController < ApiController
@status = FavouriteService.new.(current_user.account, Status.find(params[:id])).status
render action: :show
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
collection @statuses
extends('api/statuses/show')
collection @statuses
extends('api/statuses/show')
......@@ -24,6 +24,11 @@ Rails.application.routes.draw do
# JSON / REST API
resources :statuses, only: [:create, :show] do
collection do
get :home
get :mentions
end
member do
post :reblog
post :favourite
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment