preview_card_serializer.rb 496 B

123456789101112131415161718
  1. # frozen_string_literal: true
  2. class REST::PreviewCardSerializer < ActiveModel::Serializer
  3. include RoutingHelper
  4. attributes :url, :title, :description, :type,
  5. :author_name, :author_url, :provider_name,
  6. :provider_url, :html, :width, :height,
  7. :image, :embed_url, :blurhash
  8. def image
  9. object.image? ? full_asset_url(object.image.url(:original)) : nil
  10. end
  11. def html
  12. Sanitize.fragment(object.html, Sanitize::Config::MASTODON_OEMBED)
  13. end
  14. end