config: remove is_unlimited_metatag? config option.
This commit is contained in:
@@ -53,6 +53,8 @@ class PostQueryBuilder
|
||||
COUNT_METATAG_SYNONYMS.flat_map { |str| [str, "#{str}_asc"] } +
|
||||
CATEGORY_COUNT_METATAGS.flat_map { |str| [str, "#{str}_asc"] }
|
||||
|
||||
UNLIMITED_METATAGS = %w[status rating limit]
|
||||
|
||||
attr_reader :query_string, :current_user, :safe_mode, :hide_deleted_posts
|
||||
alias_method :safe_mode?, :safe_mode
|
||||
alias_method :hide_deleted_posts?, :hide_deleted_posts
|
||||
@@ -450,9 +452,13 @@ class PostQueryBuilder
|
||||
relation
|
||||
end
|
||||
|
||||
def self.is_unlimited_tag?(term)
|
||||
term.type == :metatag && term.name.in?(UNLIMITED_METATAGS)
|
||||
end
|
||||
|
||||
def build
|
||||
tag_count = terms.count { |term| !Danbooru.config.is_unlimited_tag?(term) }
|
||||
if tag_count > Danbooru.config.tag_query_limit
|
||||
tag_count = terms.count { |term| !PostQueryBuilder.is_unlimited_tag?(term) }
|
||||
if tag_count > current_user.tag_query_limit
|
||||
raise ::Post::SearchError
|
||||
end
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ module PostSets
|
||||
attr_reader :page, :random, :post_count, :format, :tag_string, :query
|
||||
delegate :normalized_query, to: :query
|
||||
|
||||
def initialize(tags, page = 1, per_page = nil, random: false, format: "html")
|
||||
@query = PostQueryBuilder.new(tags, CurrentUser.user, safe_mode: CurrentUser.safe_mode?, hide_deleted_posts: CurrentUser.hide_deleted_posts?)
|
||||
def initialize(tags, page = 1, per_page = nil, user: CurrentUser.user, random: false, format: "html")
|
||||
@query = PostQueryBuilder.new(tags, user, safe_mode: CurrentUser.safe_mode?, hide_deleted_posts: user.hide_deleted_posts?)
|
||||
@tag_string = tags
|
||||
@page = page
|
||||
@per_page = per_page
|
||||
|
||||
Reference in New Issue
Block a user