about summary refs log tree commit diff
path: root/app/serializers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-09-16 03:01:45 +0200
committerGitHub <noreply@github.com>2017-09-16 03:01:45 +0200
commit54edb4b853522b322922b65989ddfc5fdf928014 (patch)
treebf169285ecb1e9073ca0c7beaf73ed71f2666521 /app/serializers
parent6c81f9d6e553d2e9346514d1b1c8c214c317fed4 (diff)
When accessing uncached media attachment, redownload it (#4955)
* When accessing uncached media attachment, redownload it

* Prevent re-download of rejected media
Diffstat (limited to 'app/serializers')
-rw-r--r--app/serializers/rest/media_attachment_serializer.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/app/serializers/rest/media_attachment_serializer.rb b/app/serializers/rest/media_attachment_serializer.rb
index 9055b8db4..31189406a 100644
--- a/app/serializers/rest/media_attachment_serializer.rb
+++ b/app/serializers/rest/media_attachment_serializer.rb
@@ -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