diff --git a/app/logical/discord_slash_command/post_embed.rb b/app/logical/discord_slash_command/post_embed.rb
index ecd811467..be918444e 100644
--- a/app/logical/discord_slash_command/post_embed.rb
+++ b/app/logical/discord_slash_command/post_embed.rb
@@ -63,7 +63,7 @@ class DiscordSlashCommand
end
def is_censored?
- (post.rating != "s" && !is_nsfw_channel?) || !post.visible?(User.anonymous) || censored_tags.any? { |tag| tag.in?(post.tag_array) }
+ (post.rating.in?(["q", "e"]) && !is_nsfw_channel?) || !post.visible?(User.anonymous) || censored_tags.any? { |tag| tag.in?(post.tag_array) }
end
def is_nsfw_channel?
diff --git a/app/logical/discord_slash_command/wiki_command.rb b/app/logical/discord_slash_command/wiki_command.rb
index c0112c66d..69d7dd413 100644
--- a/app/logical/discord_slash_command/wiki_command.rb
+++ b/app/logical/discord_slash_command/wiki_command.rb
@@ -42,13 +42,13 @@ class DiscordSlashCommand
return nil if tag.nil? || tag.empty?
if tag.artist?
- search = "#{tag.name} rating:safe"
+ search = "#{tag.name} is:sfw"
elsif tag.copyright?
- search = "#{tag.name} rating:safe everyone copytags:<5 -parody -crossover"
+ search = "#{tag.name} is:sfw everyone copytags:<5 -parody -crossover"
elsif tag.character?
- search = "#{tag.name} rating:safe solo chartags:<5"
+ search = "#{tag.name} is:sfw solo chartags:<5"
else # meta or general
- search = "#{tag.name} rating:safe -animated -6+girls -comic"
+ search = "#{tag.name} is:sfw -animated -6+girls -comic"
end
Post.system_tag_match(search).limit(500).sort_by(&:score).last
diff --git a/app/logical/post_query.rb b/app/logical/post_query.rb
index 80bcc73b3..633c73a23 100644
--- a/app/logical/post_query.rb
+++ b/app/logical/post_query.rb
@@ -189,12 +189,12 @@ class PostQuery
TagAlias.aliases_for(tag_names)
end
- # Implicit metatags are metatags added by the user's account settings. rating:s is implicit under safe mode.
+ # 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 = Danbooru.config.safe_mode_restricted_tags.map { |tag| -AST.tag(tag) }
- [AST.metatag("rating", "s"), *tags]
+ [AST.metatag("rating", "g,s"), *tags]
end
# XXX unify with PostSets::Post#show_deleted?
diff --git a/app/models/post.rb b/app/models/post.rb
index 031bd0eac..5a659cf46 100644
--- a/app/models/post.rb
+++ b/app/models/post.rb
@@ -11,11 +11,18 @@ class Post < ApplicationRecord
RESTRICTED_TAGS_REGEX = /(?:^| )(?:#{Danbooru.config.restricted_tags.join("|")})(?:$| )/o
RATINGS = {
- s: "Safe",
+ g: "General",
+ s: "Sensitive",
q: "Questionable",
e: "Explicit",
}.with_indifferent_access
+ RATING_ALIASES = {
+ safe: ["s"],
+ nsfw: ["q", "e"],
+ sfw: ["g", "s"],
+ }.with_indifferent_access
+
deletable
has_bit_flags %w[has_embedded_notes _unused_has_cropped is_taken_down]
@@ -1064,16 +1071,14 @@ class Post < ApplicationRecord
where(has_children: true)
when "child"
where.not(parent: nil)
- when "sfw"
- where.not(rating: ["q", "e"])
- when "nsfw"
- where(rating: ["q", "e"])
when *AutocompleteService::POST_STATUSES
status_matches(value, current_user)
when *MediaAsset::FILE_TYPES
attribute_matches(value, :file_ext, :enum)
when *Post::RATINGS.values.map(&:downcase)
rating_matches(value)
+ when *Post::RATING_ALIASES.keys
+ where(rating: Post::RATING_ALIASES.fetch(value.downcase))
else
none
end
diff --git a/app/views/posts/index.sitemap.erb b/app/views/posts/index.sitemap.erb
index c1adc7ebf..f2c16798e 100644
--- a/app/views/posts/index.sitemap.erb
+++ b/app/views/posts/index.sitemap.erb
@@ -21,7 +21,7 @@