From 9d71ece55da575449e2abba8c0e2c85c02a61682 Mon Sep 17 00:00:00 2001 From: evazion Date: Fri, 22 Jan 2021 04:29:24 -0600 Subject: [PATCH] comments: remove 2 comments per hour limit. Remove the rule that Members could only post 2 bumping comments per hour. This was frequently misunderstood as meaning that Members could only post 2 comments per hour. In fact, Members could post an unlimited number of comments per hour, but the rest of their comments had to be non-bumping. The error message we showed to users was misleading. Even our own code misunderstood what this did when describing the config option. Gold users also weren't subject to this limit, which was unfair since Gold users aren't any better at commenting than regular users. The fact that a large number of users already ignored bump limits and nobody really noticed indicates that the limit was unnecessary. --- app/models/comment.rb | 7 ------- app/models/user.rb | 8 -------- app/policies/user_policy.rb | 1 - config/danbooru_default_config.rb | 5 ----- test/functional/comments_controller_test.rb | 1 - test/unit/comment_test.rb | 5 ----- 6 files changed, 27 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index ded7a5008..372e7f9c4 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,5 +1,4 @@ class Comment < ApplicationRecord - validate :validate_creator_is_not_limited, :on => :create validates_presence_of :body, :message => "has no content" belongs_to :post belongs_to :creator, class_name: "User" @@ -46,12 +45,6 @@ class Comment < ApplicationRecord extend SearchMethods - def validate_creator_is_not_limited - if creator.is_comment_limited? && !do_not_bump_post? - errors.add(:base, "You can only post #{Danbooru.config.member_comment_limit} comments per hour") - end - end - def autoreport_spam if SpamDetector.new(self).spam? moderation_reports << ModerationReport.new(creator: User.system, reason: "Spam.") diff --git a/app/models/user.rb b/app/models/user.rb index f2d6361aa..8b93c5f1a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -490,14 +490,6 @@ class User < ApplicationRecord User.max_saved_searches(level) end - def is_comment_limited? - if is_gold? - false - else - Comment.where("creator_id = ? and created_at > ?", id, 1.hour.ago).count >= Danbooru.config.member_comment_limit - end - end - def is_appeal_limited? return false if can_upload_free? upload_limit.free_upload_slots < UploadLimit::APPEAL_COST diff --git a/app/policies/user_policy.rb b/app/policies/user_policy.rb index d02848a07..faf36bec7 100644 --- a/app/policies/user_policy.rb +++ b/app/policies/user_policy.rb @@ -64,7 +64,6 @@ class UserPolicy < ApplicationPolicy custom_style favorite_count api_regen_multiplier api_burst_limit remaining_api_limit statement_timeout favorite_group_limit favorite_limit tag_query_limit - is_comment_limited? max_saved_searches theme ] end diff --git a/config/danbooru_default_config.rb b/config/danbooru_default_config.rb index 5acece016..526891393 100644 --- a/config/danbooru_default_config.rb +++ b/config/danbooru_default_config.rb @@ -102,11 +102,6 @@ module Danbooru 40 end - # Members cannot post more than X comments in an hour. - def member_comment_limit - 2 - end - # Maximum size of an upload. If you change this, you must also change # `client_max_body_size` in your nginx.conf. def max_file_size diff --git a/test/functional/comments_controller_test.rb b/test/functional/comments_controller_test.rb index 987e12605..7e1ae2a45 100644 --- a/test/functional/comments_controller_test.rb +++ b/test/functional/comments_controller_test.rb @@ -9,7 +9,6 @@ class CommentsControllerTest < ActionDispatch::IntegrationTest CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - Danbooru.config.stubs(:member_comment_limit).returns(100) end teardown do diff --git a/test/unit/comment_test.rb b/test/unit/comment_test.rb index a050cc5b1..178215f48 100644 --- a/test/unit/comment_test.rb +++ b/test/unit/comment_test.rb @@ -16,7 +16,6 @@ class CommentTest < ActiveSupport::TestCase context "that mentions a user" do setup do @post = FactoryBot.create(:post) - Danbooru.config.stubs(:member_comment_limit).returns(100) end context "added in an edit" do @@ -82,10 +81,6 @@ class CommentTest < ActiveSupport::TestCase end context "created by an unlimited user" do - setup do - Danbooru.config.stubs(:member_comment_limit).returns(100) - end - context "that is then deleted" do setup do @post = FactoryBot.create(:post)