The code powering m.abunchtell.com https://m.abunchtell.com
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

31 lignes
850 B

  1. # frozen_string_literal: true
  2. class Api::V1::Statuses::FavouritesController < Api::BaseController
  3. include Authorization
  4. before_action -> { doorkeeper_authorize! :write, :'write:favourites' }
  5. before_action :require_user!
  6. before_action :set_status
  7. respond_to :json
  8. def create
  9. FavouriteService.new.call(current_account, @status)
  10. render json: @status, serializer: REST::StatusSerializer
  11. end
  12. def destroy
  13. UnfavouriteWorker.perform_async(current_account.id, @status.id)
  14. render json: @status, serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new([@status], current_account.id, favourites_map: { @status.id => false })
  15. end
  16. private
  17. def set_status
  18. @status = Status.find(params[:status_id])
  19. authorize @status, :show?
  20. rescue Mastodon::NotPermittedError
  21. not_found
  22. end
  23. end