|
|
@ -7,15 +7,21 @@ class Api::Web::EmbedsController < Api::Web::BaseController |
|
|
|
|
|
|
|
|
|
|
|
def create |
|
|
|
def create |
|
|
|
status = StatusFinder.new(params[:url]).status |
|
|
|
status = StatusFinder.new(params[:url]).status |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return not_found if status.hidden? |
|
|
|
|
|
|
|
|
|
|
|
render json: status, serializer: OEmbedSerializer, width: 400 |
|
|
|
render json: status, serializer: OEmbedSerializer, width: 400 |
|
|
|
rescue ActiveRecord::RecordNotFound |
|
|
|
rescue ActiveRecord::RecordNotFound |
|
|
|
oembed = FetchOEmbedService.new.call(params[:url]) |
|
|
|
oembed = FetchOEmbedService.new.call(params[:url]) |
|
|
|
oembed[:html] = Formatter.instance.sanitize(oembed[:html], Sanitize::Config::MASTODON_OEMBED) if oembed[:html].present? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if oembed |
|
|
|
return not_found if oembed.nil? |
|
|
|
render json: oembed |
|
|
|
|
|
|
|
else |
|
|
|
begin |
|
|
|
render json: {}, status: :not_found |
|
|
|
oembed[:html] = Formatter.instance.sanitize(oembed[:html], Sanitize::Config::MASTODON_OEMBED) |
|
|
|
|
|
|
|
rescue ArgumentError |
|
|
|
|
|
|
|
return not_found |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
render json: oembed |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|