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.

57 lines
1.4 KiB

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