The code powering m.abunchtell.com https://m.abunchtell.com
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

53 linhas
1.3 KiB

  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.call(current_user.account, @account.acct)
  18. set_relationship
  19. render action: :relationship
  20. end
  21. def unfollow
  22. @unfollow = UnfollowService.new.call(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(&: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