media assets: remove image links for deleted images.

Don't show dead direct image links, reverse search links, or source links for deleted media assets.
This commit is contained in:
evazion
2022-11-29 22:05:29 -06:00
parent a2d9154125
commit 05143dc9fa
4 changed files with 15 additions and 9 deletions

View File

@@ -27,6 +27,8 @@ class MediaAsset < ApplicationRecord
scope :public_only, -> { where(is_public: true) }
scope :private_only, -> { where(is_public: false) }
scope :without_ai_tags, -> { where.not(AITag.where("ai_tags.media_asset_id = media_assets.id").select(1).arel.exists) }
scope :removed, -> { where(status: [:deleted, :expunged]) }
scope :expired, -> { processing.where(created_at: ..4.hours.ago) }
# Processing: The asset's files are currently being resized and distributed to the backend servers.
# Active: The asset has been successfully uploaded and is ready to use.
@@ -51,8 +53,6 @@ class MediaAsset < ApplicationRecord
before_create :initialize_file_key
scope :expired, -> { processing.where(created_at: ..4.hours.ago) }
def self.prune!
expired.update_all(status: :failed)
end
@@ -321,6 +321,10 @@ class MediaAsset < ApplicationRecord
end
end
def removed?
deleted? || expunged?
end
# @return [Mime::Type] The file's MIME type.
def mime_type
Mime::Type.lookup_by_extension(file_ext)