diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-09-16 03:01:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-16 03:01:45 +0200 |
commit | 54edb4b853522b322922b65989ddfc5fdf928014 (patch) | |
tree | bf169285ecb1e9073ca0c7beaf73ed71f2666521 /app/models | |
parent | 6c81f9d6e553d2e9346514d1b1c8c214c317fed4 (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/models')
-rw-r--r-- | app/models/media_attachment.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb index d83ca44f1..d913e7372 100644 --- a/app/models/media_attachment.rb +++ b/app/models/media_attachment.rb @@ -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 |