闭社主体 forked from https://github.com/tootsuite/mastodon
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.

17 lines
471 B

  1. # frozen_string_literal: true
  2. class Api::Web::EmbedsController < Api::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 = OEmbed::Providers.get(params[:url])
  10. render json: Oj.dump(oembed.fields)
  11. rescue OEmbed::NotFound
  12. render json: {}, status: :not_found
  13. end
  14. end