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.

54 lines
1.5 KiB

7 years ago
7 years ago
  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]).to_a
  40. end
  41. def mentions
  42. @statuses = Feed.new(:mentions, current_user.account).get(20, params[:max_id]).to_a
  43. end
  44. end