]> cat aescling's git repositories - mastodon.git/blob - app/controllers/api/v1/accounts_controller.rb
Add since_id param to feeds
[mastodon.git] / app / controllers / api / v1 / accounts_controller.rb
1 class Api::V1::AccountsController < ApiController
2 before_action :doorkeeper_authorize!
3 before_action :set_account, except: :verify_credentials
4 respond_to :json
5
6 def show
7 end
8
9 def verify_credentials
10 @account = current_user.account
11 render action: :show
12 end
13
14 def following
15 @following = @account.following
16 end
17
18 def followers
19 @followers = @account.followers
20 end
21
22 def statuses
23 @statuses = @account.statuses.with_includes.with_counters.paginate_by_max_id(20, params[:max_id], params[:since_id]).to_a
24 end
25
26 def follow
27 @follow = FollowService.new.call(current_user.account, @account.acct)
28 set_relationship
29 render action: :relationship
30 end
31
32 def unfollow
33 @unfollow = UnfollowService.new.call(current_user.account, @account)
34 set_relationship
35 render action: :relationship
36 end
37
38 def relationships
39 ids = params[:id].is_a?(Enumerable) ? params[:id].map(&:to_i) : [params[:id].to_i]
40 @accounts = Account.find(ids)
41 @following = Account.following_map(ids, current_user.account_id)
42 @followed_by = Account.followed_by_map(ids, current_user.account_id)
43 @blocking = {}
44 end
45
46 private
47
48 def set_account
49 @account = Account.find(params[:id])
50 end
51
52 def set_relationship
53 @following = Account.following_map([@account.id], current_user.account_id)
54 @followed_by = Account.followed_by_map([@account.id], current_user.account_id)
55 @blocking = {}
56 end
57 end
This page took 0.081177 seconds and 4 git commands to generate.