闭社主体 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.

21 lines
586 B

7 years ago
  1. # frozen_string_literal: true
  2. class Api::OEmbedController < ApiController
  3. respond_to :json
  4. def show
  5. @stream_entry = stream_entry_from_url(params[:url])
  6. @width = params[:maxwidth].present? ? params[:maxwidth].to_i : 400
  7. @height = params[:maxheight].present? ? params[:maxheight].to_i : 600
  8. end
  9. private
  10. def stream_entry_from_url(url)
  11. params = Rails.application.routes.recognize_path(url)
  12. raise ActiveRecord::NotFound unless params[:controller] == 'stream_entries' && params[:action] == 'show'
  13. StreamEntry.find(params[:id])
  14. end
  15. end