embeds_controller.rb 476 B

1234567891011121314151617181920
  1. # frozen_string_literal: true
  2. class Api::Web::EmbedsController < Api::Web::BaseController
  3. respond_to :json
  4. before_action :require_user!
  5. def create
  6. status = StatusFinder.new(params[:url]).status
  7. render json: status, serializer: OEmbedSerializer, width: 400
  8. rescue ActiveRecord::RecordNotFound
  9. oembed = FetchOEmbedService.new.call(params[:url])
  10. if oembed
  11. render json: oembed
  12. else
  13. render json: {}, status: :not_found
  14. end
  15. end
  16. end