]>
cat aescling's git repositories - mastodon.git/blob - app/controllers/media_proxy_controller.rb
1 # frozen_string_literal: true
3 class MediaProxyController
< ApplicationController
6 skip_before_action
:store_current_location
7 skip_before_action
:require_functional!
9 before_action
:authenticate_user!
, if: :whitelist_mode?
11 rescue_from ActiveRecord
::RecordInvalid, with
: :not_found
12 rescue_from Mastodon
::UnexpectedResponseError, with
: :not_found
13 rescue_from HTTP
::TimeoutError, HTTP
::ConnectionError, OpenSSL
::SSL::SSLError, with
: :internal_server_error
16 RedisLock
.acquire(lock_options
) do |lock
|
18 @media_attachment = MediaAttachment
.remote
.find(params
[:id])
19 redownload!
if @media_attachment.needs_redownload
? && !reject_media
?
21 raise Mastodon
::RaceConditionError
25 redirect_to
full_asset_url(@media_attachment.file
.url(version))
31 @media_attachment.download_file!
32 @media_attachment.created_at
= Time
.now
.utc
33 @media_attachment.save!
37 if request
.path
.ends_with
?('/small')
45 { redis
: Redis
.current
, key
: "media_download:#{params[:id]}" }
49 DomainBlock
.reject_media
?(@media_attachment.account
.domain
)
This page took 0.090888 seconds and 4 git commands to generate.