diff --git a/app/logical/post_query.rb b/app/logical/post_query.rb index fb1a12e52..08f5d2f10 100644 --- a/app/logical/post_query.rb +++ b/app/logical/post_query.rb @@ -208,10 +208,28 @@ def aliases # Implicit metatags are metatags added by the user's account settings. rating:g,s is implicit under safe mode. def implicit_metatags - return [] unless safe_mode? + tags = [] - tags = Danbooru.config.safe_mode_restricted_tags.map { |tag| -AST.tag(tag) } - [AST.metatag("rating", "g"), *tags] + if safe_mode? + tags = Danbooru.config.safe_mode_restricted_tags.map { |tag| -AST.tag(tag) } + [AST.metatag("rating", "g"), *tags] + end + + unless show_deleted? + tags << AST.metatag("status", "deleted").-@ + end + + tags + end + + def show_deleted? + current_user.show_deleted_posts? || has_status_metatag? + end + + def has_status_metatag? + select_metatags("is", "status").any? do |metatag| + metatag.value.downcase.in?(%w[all any active unmoderated modqueue deleted appealed]) + end end concerning :CountMethods do diff --git a/app/logical/post_sets/post.rb b/app/logical/post_sets/post.rb index 220516327..e554abb0f 100644 --- a/app/logical/post_sets/post.rb +++ b/app/logical/post_sets/post.rb @@ -13,7 +13,7 @@ class Post MAX_WILDCARD_TAGS = PostQueryBuilder::MAX_WILDCARD_TAGS attr_reader :current_user, :page, :format, :tag_string, :post_query, :normalized_query, :show_votes, :add_extra_data_attributes - delegate :tag, to: :post_query + delegate :tag, :show_deleted?, to: :post_query alias_method :show_votes?, :show_votes alias_method :add_extra_data_attributes?, :add_extra_data_attributes @@ -133,16 +133,6 @@ def best_post posts.reject(&:is_deleted).select(&:visible?).max_by { |post| [-post.rating_id, post.score] } end - def show_deleted? - current_user.show_deleted_posts? || has_status_metatag? - end - - def has_status_metatag? - post_query.select_metatags("is", "status").any? do |metatag| - metatag.value.downcase.in?(%w[all any active unmoderated modqueue deleted appealed]) - end - end - def banned_artist? artist.present? && artist.is_banned? && !current_user.is_approver? end