accounts_controller.rb 662 B

123456789101112131415161718192021222324252627282930313233343536
  1. class Api::AccountsController < ApiController
  2. before_action :set_account
  3. before_action :doorkeeper_authorize!
  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_counts.order('created_at desc')
  15. end
  16. def follow
  17. @follow = current_user.account.follow!(@account)
  18. render action: :show
  19. end
  20. def unfollow
  21. @unfollow = current_user.account.unfollow!(@account)
  22. render action: :show
  23. end
  24. private
  25. def set_account
  26. @account = Account.find(params[:id])
  27. end
  28. end