config: remove more obsolete or unneeded config options.
Remove more config options that were either unused or that shouldn't need to be configured by downstream users.
This commit is contained in:
@@ -3,14 +3,13 @@ class StorageManager
|
|||||||
|
|
||||||
DEFAULT_BASE_DIR = "#{Rails.root}/public/data"
|
DEFAULT_BASE_DIR = "#{Rails.root}/public/data"
|
||||||
|
|
||||||
attr_reader :base_url, :base_dir, :hierarchical, :tagged_filenames, :large_image_prefix, :original_subdir
|
attr_reader :base_url, :base_dir, :hierarchical, :tagged_filenames, :original_subdir
|
||||||
|
|
||||||
def initialize(base_url: default_base_url, base_dir: DEFAULT_BASE_DIR, hierarchical: false, tagged_filenames: Danbooru.config.enable_seo_post_urls, large_image_prefix: Danbooru.config.large_image_prefix, original_subdir: "")
|
def initialize(base_url: default_base_url, base_dir: DEFAULT_BASE_DIR, hierarchical: false, tagged_filenames: Danbooru.config.enable_seo_post_urls, original_subdir: "")
|
||||||
@base_url = base_url.chomp("/")
|
@base_url = base_url.chomp("/")
|
||||||
@base_dir = base_dir
|
@base_dir = base_dir
|
||||||
@hierarchical = hierarchical
|
@hierarchical = hierarchical
|
||||||
@tagged_filenames = tagged_filenames
|
@tagged_filenames = tagged_filenames
|
||||||
@large_image_prefix = large_image_prefix
|
|
||||||
@original_subdir = original_subdir
|
@original_subdir = original_subdir
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -99,7 +98,7 @@ class StorageManager
|
|||||||
when :crop
|
when :crop
|
||||||
"#{md5}.jpg"
|
"#{md5}.jpg"
|
||||||
when :large
|
when :large
|
||||||
"#{large_image_prefix}#{md5}.#{large_file_ext}"
|
"sample-#{md5}.#{large_file_ext}"
|
||||||
when :original
|
when :original
|
||||||
"#{md5}.#{file_ext}"
|
"#{md5}.#{file_ext}"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -168,8 +168,6 @@ class UploadService
|
|||||||
end
|
end
|
||||||
|
|
||||||
def automatic_tags(upload, file)
|
def automatic_tags(upload, file)
|
||||||
return "" unless Danbooru.config.enable_dimension_autotagging
|
|
||||||
|
|
||||||
tags = []
|
tags = []
|
||||||
tags << "video_with_sound" if is_video_with_audio?(upload, file)
|
tags << "video_with_sound" if is_video_with_audio?(upload, file)
|
||||||
tags << "animated_gif" if is_animated_gif?(upload, file)
|
tags << "animated_gif" if is_animated_gif?(upload, file)
|
||||||
|
|||||||
@@ -671,8 +671,6 @@ class Post < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def add_automatic_tags(tags)
|
def add_automatic_tags(tags)
|
||||||
return tags if !Danbooru.config.enable_dimension_autotagging
|
|
||||||
|
|
||||||
tags -= %w(incredibly_absurdres absurdres highres lowres huge_filesize flash webm mp4)
|
tags -= %w(incredibly_absurdres absurdres highres lowres huge_filesize flash webm mp4)
|
||||||
|
|
||||||
if has_dimensions?
|
if has_dimensions?
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
class PostAppeal < ApplicationRecord
|
class PostAppeal < ApplicationRecord
|
||||||
class Error < Exception; end
|
class Error < Exception; end
|
||||||
|
|
||||||
|
MAX_APPEALS_PER_DAY = 1
|
||||||
|
|
||||||
belongs_to :creator, :class_name => "User"
|
belongs_to :creator, :class_name => "User"
|
||||||
belongs_to :post
|
belongs_to :post
|
||||||
validates_presence_of :reason
|
validates_presence_of :reason
|
||||||
@@ -47,8 +49,8 @@ class PostAppeal < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def validate_creator_is_not_limited
|
def validate_creator_is_not_limited
|
||||||
if appeal_count_for_creator >= Danbooru.config.max_appeals_per_day
|
if appeal_count_for_creator >= MAX_APPEALS_PER_DAY
|
||||||
errors[:creator] << "can appeal at most #{Danbooru.config.max_appeals_per_day} post a day"
|
errors[:creator] << "can appeal at most #{MAX_APPEALS_PER_DAY} post a day"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class Upload < ApplicationRecord
|
|||||||
def initialize_attributes
|
def initialize_attributes
|
||||||
self.uploader_id = CurrentUser.id
|
self.uploader_id = CurrentUser.id
|
||||||
self.uploader_ip_addr = CurrentUser.ip_addr
|
self.uploader_ip_addr = CurrentUser.ip_addr
|
||||||
self.server = Danbooru.config.server_host
|
self.server = Socket.gethostname
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.prune!(date = 1.day.ago)
|
def self.prune!(date = 1.day.ago)
|
||||||
|
|||||||
@@ -244,7 +244,8 @@ class User < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def sha1(pass)
|
def sha1(pass)
|
||||||
Digest::SHA1.hexdigest("#{Danbooru.config.password_salt}--#{pass}--")
|
salt = "choujin-steiner"
|
||||||
|
Digest::SHA1.hexdigest("#{salt}--#{pass}--")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ module Danbooru
|
|||||||
|
|
||||||
# Contact email address of the admin.
|
# Contact email address of the admin.
|
||||||
def contact_email
|
def contact_email
|
||||||
"webmaster@#{server_host}"
|
"webmaster@#{hostname}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# System actions, such as sending automated dmails, will be performed with
|
# System actions, such as sending automated dmails, will be performed with
|
||||||
@@ -64,11 +64,6 @@ module Danbooru
|
|||||||
"#{source_code_url}/issues"
|
"#{source_code_url}/issues"
|
||||||
end
|
end
|
||||||
|
|
||||||
# This is a salt used to make dictionary attacks on account passwords harder.
|
|
||||||
def password_salt
|
|
||||||
"choujin-steiner"
|
|
||||||
end
|
|
||||||
|
|
||||||
# Set the default level, permissions, and other settings for new users here.
|
# Set the default level, permissions, and other settings for new users here.
|
||||||
def customize_new_user(user)
|
def customize_new_user(user)
|
||||||
# user.level = User::Levels::MEMBER
|
# user.level = User::Levels::MEMBER
|
||||||
@@ -94,15 +89,6 @@ module Danbooru
|
|||||||
850
|
850
|
||||||
end
|
end
|
||||||
|
|
||||||
def large_image_prefix
|
|
||||||
"sample-"
|
|
||||||
end
|
|
||||||
|
|
||||||
# When calculating statistics based on the posts table, gather this many posts to sample from.
|
|
||||||
def post_sample_size
|
|
||||||
300
|
|
||||||
end
|
|
||||||
|
|
||||||
# After a post receives this many comments, new comments will no longer bump the post in comment/index.
|
# After a post receives this many comments, new comments will no longer bump the post in comment/index.
|
||||||
def comment_threshold
|
def comment_threshold
|
||||||
40
|
40
|
||||||
@@ -177,11 +163,6 @@ module Danbooru
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
# The name of the server the app is hosted on.
|
|
||||||
def server_host
|
|
||||||
Socket.gethostname
|
|
||||||
end
|
|
||||||
|
|
||||||
# The method to use for storing image files.
|
# The method to use for storing image files.
|
||||||
def storage_manager
|
def storage_manager
|
||||||
# Store files on the local filesystem.
|
# Store files on the local filesystem.
|
||||||
@@ -343,10 +324,6 @@ module Danbooru
|
|||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
def max_appeals_per_day
|
|
||||||
1
|
|
||||||
end
|
|
||||||
|
|
||||||
# Counting every post is typically expensive because it involves a sequential scan on
|
# Counting every post is typically expensive because it involves a sequential scan on
|
||||||
# potentially millions of rows. If this method returns a value, then blank searches
|
# potentially millions of rows. If this method returns a value, then blank searches
|
||||||
# will return that number for the fast_count call instead.
|
# will return that number for the fast_count call instead.
|
||||||
@@ -403,10 +380,6 @@ module Danbooru
|
|||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def enable_dimension_autotagging
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
# Should return true if the given tag should be suggested for removal in the post replacement dialog box.
|
# Should return true if the given tag should be suggested for removal in the post replacement dialog box.
|
||||||
def remove_tag_after_replacement?(tag)
|
def remove_tag_after_replacement?(tag)
|
||||||
tag =~ /\A(?:replaceme|.*_sample|resized|upscaled|downscaled|md5_mismatch|jpeg_artifacts|corrupted_image|source_request|non-web_source)\z/i
|
tag =~ /\A(?:replaceme|.*_sample|resized|upscaled|downscaled|md5_mismatch|jpeg_artifacts|corrupted_image|source_request|non-web_source)\z/i
|
||||||
@@ -455,11 +428,6 @@ module Danbooru
|
|||||||
"zDMSATq0W3hmA5p3rKTgD"
|
"zDMSATq0W3hmA5p3rKTgD"
|
||||||
end
|
end
|
||||||
|
|
||||||
# impose additional requirements to create tag aliases and implications
|
|
||||||
def strict_tag_requirements
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
# For downloads, if the host matches any of these IPs, block it
|
# For downloads, if the host matches any of these IPs, block it
|
||||||
def banned_ip_for_download?(ip_addr)
|
def banned_ip_for_download?(ip_addr)
|
||||||
raise ArgumentError unless ip_addr.is_a?(IPAddr)
|
raise ArgumentError unless ip_addr.is_a?(IPAddr)
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ class PostAppealTest < ActiveSupport::TestCase
|
|||||||
@alice = FactoryBot.create(:user)
|
@alice = FactoryBot.create(:user)
|
||||||
CurrentUser.user = @alice
|
CurrentUser.user = @alice
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
Danbooru.config.stubs(:max_appeals_per_day).returns(5)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
@@ -28,16 +27,16 @@ class PostAppealTest < ActiveSupport::TestCase
|
|||||||
@post_appeal = PostAppeal.create(:post => @post, :reason => "aaa")
|
@post_appeal = PostAppeal.create(:post => @post, :reason => "aaa")
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal(["You have already appealed this post"], @post_appeal.errors.full_messages)
|
assert_includes(@post_appeal.errors.full_messages, "You have already appealed this post")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not be able to appeal more than 5 posts in 24 hours" do
|
should "not be able to appeal more than 1 post in 24 hours" do
|
||||||
@post_appeal = PostAppeal.new(:post => @post, :reason => "aaa")
|
@post_appeal = PostAppeal.new(:post => @post, :reason => "aaa")
|
||||||
@post_appeal.expects(:appeal_count_for_creator).returns(5)
|
@post_appeal.expects(:appeal_count_for_creator).returns(1)
|
||||||
assert_difference("PostAppeal.count", 0) do
|
assert_difference("PostAppeal.count", 0) do
|
||||||
@post_appeal.save
|
@post_appeal.save
|
||||||
end
|
end
|
||||||
assert_equal(["You can appeal at most 5 post a day"], @post_appeal.errors.full_messages)
|
assert_equal(["You can appeal at most 1 post a day"], @post_appeal.errors.full_messages)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not be able to appeal an active post" do
|
should "not be able to appeal an active post" do
|
||||||
|
|||||||
Reference in New Issue
Block a user