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.

61 lines
1.8 KiB

  1. class Api::V1::StatusesController < ApiController
  2. before_action :doorkeeper_authorize!
  3. respond_to :json
  4. def show
  5. @status = Status.find(params[:id])
  6. end
  7. def context
  8. @status = Status.find(params[:id])
  9. @ancestors = @status.ancestors
  10. @descendants = @status.descendants
  11. end
  12. def create
  13. @status = PostStatusService.new.call(current_user.account, params[:status], params[:in_reply_to_id].blank? ? nil : Status.find(params[:in_reply_to_id]), params[:media_ids])
  14. render action: :show
  15. end
  16. def destroy
  17. @status = Status.where(account_id: current_user.account).find(params[:id])
  18. RemoveStatusService.new.call(@status)
  19. render_empty
  20. end
  21. def reblog
  22. @status = ReblogService.new.call(current_user.account, Status.find(params[:id])).reload
  23. render action: :show
  24. end
  25. def unreblog
  26. RemoveStatusService.new.call(Status.where(account_id: current_user.account, reblog_of_id: params[:id]).first!)
  27. @status = Status.find(params[:id])
  28. render action: :show
  29. end
  30. def favourite
  31. @status = FavouriteService.new.call(current_user.account, Status.find(params[:id])).status.reload
  32. render action: :show
  33. end
  34. def unfavourite
  35. @status = UnfavouriteService.new.call(current_user.account, Status.find(params[:id])).status.reload
  36. render action: :show
  37. end
  38. def home
  39. @statuses = Feed.new(:home, current_user.account).get(20, params[:max_id], params[:since_id]).to_a
  40. render action: :index
  41. end
  42. def mentions
  43. @statuses = Feed.new(:mentions, current_user.account).get(20, params[:max_id], params[:since_id]).to_a
  44. render action: :index
  45. end
  46. def public
  47. @statuses = Status.with_includes.with_counters.order('id desc').paginate_by_max_id(20, params[:max_id], params[:since_id]).to_a
  48. render action: :index
  49. end
  50. end