The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

27 lines
570 B

  1. # frozen_string_literal: true
  2. class Api::OEmbedController < Api::BaseController
  3. respond_to :json
  4. skip_before_action :require_authenticated_user!
  5. def show
  6. @status = status_finder.status
  7. render json: @status, serializer: OEmbedSerializer, width: maxwidth_or_default, height: maxheight_or_default
  8. end
  9. private
  10. def status_finder
  11. StatusFinder.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