logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

oembed_controller.rb (519B)


  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