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.

25 lines
526 B

  1. # frozen_string_literal: true
  2. class Api::V1::FollowsController < Api::BaseController
  3. before_action -> { doorkeeper_authorize! :follow }
  4. before_action :require_user!
  5. respond_to :json
  6. def create
  7. raise ActiveRecord::RecordNotFound if follow_params[:uri].blank?
  8. @account = FollowService.new.call(current_user.account, target_uri).try(:target_account)
  9. render :show
  10. end
  11. private
  12. def target_uri
  13. follow_params[:uri].strip.gsub(/\A@/, '')
  14. end
  15. def follow_params
  16. params.permit(:uri)
  17. end
  18. end