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

25 lines
499 B

  1. # frozen_string_literal: true
  2. class Api::OEmbedController < Api::BaseController
  3. respond_to :json
  4. def show
  5. @stream_entry = find_stream_entry.stream_entry
  6. @width = maxwidth_or_default
  7. @height = maxheight_or_default
  8. end
  9. private
  10. def find_stream_entry
  11. StreamEntryFinder.new(params[:url])
  12. end
  13. def maxwidth_or_default
  14. (params[:maxwidth].presence || 400).to_i
  15. end
  16. def maxheight_or_default
  17. params[:maxheight].present? ? params[:maxheight].to_i : nil
  18. end
  19. end