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.

20 lines
476 B

  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