Files
danbooru/app/policies/media_asset_policy.rb
evazion 05143dc9fa 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.
2022-11-29 22:18:21 -06:00

26 lines
435 B
Ruby

# frozen_string_literal: true
class MediaAssetPolicy < ApplicationPolicy
def index?
true
end
def destroy?
user.is_admin?
end
def image?
can_see_image?
end
def can_see_image?
!record.removed? && (record.post.blank? || record.post.visible?(user))
end
def api_attributes
attributes = super + [:variants]
attributes -= [:md5, :file_key, :variants] if !can_see_image?
attributes
end
end