This repository has been archived on 2019-05-14. You can view files and clone it, but cannot push or open issues or pull requests.
mastodon/app/controllers/api/oembed_controller.rb
Matt Jankowski 73540ffe6b Clean up for api/base controller (#3629)
* Move ApiController to Api/BaseController

* API controllers inherit from Api::BaseController

* Add coverage for various error cases in api/base controller
2017-06-07 20:09:25 +02:00

26 lines
499 B
Ruby

# frozen_string_literal: true
class Api::OEmbedController < Api::BaseController
respond_to :json
def show
@stream_entry = find_stream_entry.stream_entry
@width = maxwidth_or_default
@height = maxheight_or_default
end
private
def find_stream_entry
StreamEntryFinder.new(params[:url])
end
def maxwidth_or_default
(params[:maxwidth].presence || 400).to_i
end
def maxheight_or_default
params[:maxheight].present? ? params[:maxheight].to_i : nil
end
end