When accessing uncached media attachment, redownload it (#4955)

* When accessing uncached media attachment, redownload it

* Prevent re-download of rejected media
This commit is contained in:
Eugen Rochko
2017-09-16 03:01:45 +02:00
committed by GitHub
parent 6c81f9d6e5
commit 54edb4b853
5 changed files with 60 additions and 5 deletions

View File

@ -7,11 +7,19 @@ class REST::MediaAttachmentSerializer < ActiveModel::Serializer
:remote_url, :text_url, :meta
def url
full_asset_url(object.file.url(:original))
if object.needs_redownload?
media_proxy_url(object.id, :original)
else
full_asset_url(object.file.url(:original))
end
end
def preview_url
full_asset_url(object.file.url(:small))
if object.needs_redownload?
media_proxy_url(object.id, :small)
else
full_asset_url(object.file.url(:small))
end
end
def text_url