diff options
author | Thibaut Girka <thib@sitedethib.com> | 2020-02-09 12:15:55 +0100 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2020-02-09 12:15:55 +0100 |
commit | dae5e446fe7294dba0e14311ef3da4dc8fff6a3a (patch) | |
tree | 33a76386b1e8bc9c968bfc49409f72000b7ec410 /app/controllers/api | |
parent | a2cfe3daaadabfaad71969a44c460bd76b8405ff (diff) | |
parent | 57c42c20c01b46f0d7cad5a357d56190274a3fa1 (diff) |
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts: - `Gemfile`: We updated httplog in a separate commit. Took upstream's change which updated it further. - `Gemfile.lock`: We updated httplog in a separate commit. Took upstream's change which updated it further. - `app/lib/sanitize_config.rb`: Upstream added better unsupported link stripping, while we had different sanitizing configs. Took only upstream's link stripping code. - `config/locales/simple_form.pl.yml`: Strings unused in glitch-soc had been removed from glitch-soc, reintroduced them even if they are not useful, to reduce the risk of later merge conflicts.
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 |