]> cat aescling's git repositories - mastodon.git/blob - app/controllers/api/v1/accounts_controller.rb
Fix #52 - Add API versioning (v1)
[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
4 respond_to :json
5
6 def show
7 end
8
9 def following
10 @following = @account.following
11 end
12
13 def followers
14 @followers = @account.followers
15 end
16
17 def statuses
18 @statuses = @account.statuses.with_includes.with_counters.paginate_by_max_id(20, params[:max_id] || nil).to_a
19 end
20
21 def follow
22 @follow = FollowService.new.(current_user.account, @account.acct)
23 set_relationship
24 render action: :relationship
25 end
26
27 def unfollow
28 @unfollow = UnfollowService.new.(current_user.account, @account)
29 set_relationship
30 render action: :relationship
31 end
32
33 def relationships
34 ids = params[:id].is_a?(Enumerable) ? params[:id].map { |id| id.to_i } : [params[:id].to_i]
35 @accounts = Account.find(ids)
36 @following = Account.following_map(ids, current_user.account_id)
37 @followed_by = Account.followed_by_map(ids, current_user.account_id)
38 @blocking = {}
39 end
40
41 private
42
43 def set_account
44 @account = Account.find(params[:id])
45 end
46
47 def set_relationship
48 @following = Account.following_map([@account.id], current_user.account_id)
49 @followed_by = Account.followed_by_map([@account.id], current_user.account_id)
50 @blocking = {}
51 end
52 end
This page took 0.101582 seconds and 5 git commands to generate.