You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.3 KiB

7 years ago
  1. class Api::V1::AccountsController < ApiController
  2. before_action :doorkeeper_authorize!
  3. before_action :set_account
  4. respond_to :json
  5. def show
  6. end
  7. def following
  8. @following = @account.following
  9. end
  10. def followers
  11. @followers = @account.followers
  12. end
  13. def statuses
  14. @statuses = @account.statuses.with_includes.with_counters.paginate_by_max_id(20, params[:max_id] || nil).to_a
  15. end
  16. def follow
  17. @follow = FollowService.new.(current_user.account, @account.acct)
  18. set_relationship
  19. render action: :relationship
  20. end
  21. def unfollow
  22. @unfollow = UnfollowService.new.(current_user.account, @account)
  23. set_relationship
  24. render action: :relationship
  25. end
  26. def relationships
  27. ids = params[:id].is_a?(Enumerable) ? params[:id].map { |id| id.to_i } : [params[:id].to_i]
  28. @accounts = Account.find(ids)
  29. @following = Account.following_map(ids, current_user.account_id)
  30. @followed_by = Account.followed_by_map(ids, current_user.account_id)
  31. @blocking = {}
  32. end
  33. private
  34. def set_account
  35. @account = Account.find(params[:id])
  36. end
  37. def set_relationship
  38. @following = Account.following_map([@account.id], current_user.account_id)
  39. @followed_by = Account.followed_by_map([@account.id], current_user.account_id)
  40. @blocking = {}
  41. end
  42. end