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.

65 lines
1.9 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. set_maps([@status] + @ancestors + @descendants)
  12. end
  13. def create
  14. @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])
  15. render action: :show
  16. end
  17. def destroy
  18. @status = Status.where(account_id: current_user.account).find(params[:id])
  19. RemoveStatusService.new.call(@status)
  20. render_empty
  21. end
  22. def reblog
  23. @status = ReblogService.new.call(current_user.account, Status.find(params[:id])).reload
  24. render action: :show
  25. end
  26. def unreblog
  27. RemoveStatusService.new.call(Status.where(account_id: current_user.account, reblog_of_id: params[:id]).first!)
  28. @status = Status.find(params[:id])
  29. render action: :show
  30. end
  31. def favourite
  32. @status = FavouriteService.new.call(current_user.account, Status.find(params[:id])).status.reload
  33. render action: :show
  34. end
  35. def unfavourite
  36. @status = UnfavouriteService.new.call(current_user.account, Status.find(params[:id])).status.reload
  37. render action: :show
  38. end
  39. def home
  40. @statuses = Feed.new(:home, current_user.account).get(20, params[:max_id], params[:since_id]).to_a
  41. set_maps(@statuses)
  42. render action: :index
  43. end
  44. def mentions
  45. @statuses = Feed.new(:mentions, current_user.account).get(20, params[:max_id], params[:since_id]).to_a
  46. set_maps(@statuses)
  47. render action: :index
  48. end
  49. def public
  50. @statuses = Status.as_public_timeline(current_user.account).paginate_by_max_id(20, params[:max_id], params[:since_id]).to_a
  51. set_maps(@statuses)
  52. render action: :index
  53. end
  54. end