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

@ -56,15 +56,21 @@ class MediaAttachment < ApplicationRecord
validates :account, presence: true
scope :attached, -> { where.not(status_id: nil) }
scope :attached, -> { where.not(status_id: nil) }
scope :unattached, -> { where(status_id: nil) }
scope :local, -> { where(remote_url: '') }
scope :local, -> { where(remote_url: '') }
scope :remote, -> { where.not(remote_url: '') }
default_scope { order(id: :asc) }
def local?
remote_url.blank?
end
def needs_redownload?
file.blank? && remote_url.present?
end
def to_param
shortcode
end