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.

24 lines
519 B

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