diff options
author | Starfall <root@starfall.blue> | 2020-02-13 17:55:53 -0600 |
---|---|---|
committer | Starfall <root@starfall.blue> | 2020-02-13 17:55:53 -0600 |
commit | 5902299384d15249fe4b84b8761d4a49f3c7f6fd (patch) | |
tree | 66f1db08a2f6f9ae2254ba7a81b71835039d671e /app/controllers/api | |
parent | 6d24d3bcb84abd04f31da95f97f6d60ef0afdc00 (diff) | |
parent | 0cbd6d696b8937066cde297ad2eae4b558353b7c (diff) |
Merge branch 'glitch'
Diffstat (limited to 'app/controllers/api')
-rw-r--r-- | app/controllers/api/web/embeds_controller.rb | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/app/controllers/api/web/embeds_controller.rb b/app/controllers/api/web/embeds_controller.rb index 6231733b7..4aa31695c 100644 --- a/app/controllers/api/web/embeds_controller.rb +++ b/app/controllers/api/web/embeds_controller.rb @@ -7,15 +7,21 @@ class Api::Web::EmbedsController < Api::Web::BaseController def create status = StatusFinder.new(params[:url]).status + + return not_found if status.hidden? + render json: status, serializer: OEmbedSerializer, width: 400 rescue ActiveRecord::RecordNotFound oembed = FetchOEmbedService.new.call(params[:url]) - oembed[:html] = Formatter.instance.sanitize(oembed[:html], Sanitize::Config::MASTODON_OEMBED) if oembed[:html].present? - if oembed - render json: oembed - else - render json: {}, status: :not_found + return not_found if oembed.nil? + + begin + oembed[:html] = Formatter.instance.sanitize(oembed[:html], Sanitize::Config::MASTODON_OEMBED) + rescue ArgumentError + return not_found end + + render json: oembed end end |