logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

embeds_controller.rb (471B)


  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