Add Reviewable
model concern (#31152)
This commit is contained in:
parent
2f0d0fc127
commit
7c26e5e4a1
8 changed files with 85 additions and 48 deletions
|
@ -21,6 +21,7 @@ class PreviewCardProvider < ApplicationRecord
|
|||
include Paginable
|
||||
include DomainNormalizable
|
||||
include Attachmentable
|
||||
include Reviewable
|
||||
|
||||
ICON_MIME_TYPES = %w(image/x-icon image/vnd.microsoft.icon image/png).freeze
|
||||
LIMIT = 1.megabyte
|
||||
|
@ -36,22 +37,6 @@ class PreviewCardProvider < ApplicationRecord
|
|||
scope :reviewed, -> { where.not(reviewed_at: nil) }
|
||||
scope :pending_review, -> { where(reviewed_at: nil) }
|
||||
|
||||
def requires_review?
|
||||
reviewed_at.nil?
|
||||
end
|
||||
|
||||
def reviewed?
|
||||
reviewed_at.present?
|
||||
end
|
||||
|
||||
def requested_review?
|
||||
requested_review_at.present?
|
||||
end
|
||||
|
||||
def requires_review_notification?
|
||||
requires_review? && !requested_review?
|
||||
end
|
||||
|
||||
def self.matching_domain(domain)
|
||||
segments = domain.split('.')
|
||||
where(domain: segments.map.with_index { |_, i| segments[i..].join('.') }).by_domain_length.first
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue