disapprovals: don't dmail uploaders about disapprovals.
Remove sending dmail notifications to uploaders when an upload is disapproved. These messages are usually confusing and frustrating to uploaders. They don't know who is sending them and they usually feel insulted when they get negative messages from anonymous users.
This commit is contained in:
@@ -9,7 +9,6 @@ module DanbooruMaintenance
|
||||
safely { Upload.prune! }
|
||||
safely { Delayed::Job.where('created_at < ?', 45.days.ago).delete_all }
|
||||
safely { PostDisapproval.prune! }
|
||||
safely { PostDisapproval.dmail_messages! }
|
||||
safely { regenerate_post_counts! }
|
||||
safely { TokenBucket.prune! }
|
||||
safely { BulkUpdateRequestPruner.warn_old }
|
||||
|
||||
@@ -18,24 +18,6 @@ class PostDisapproval < ApplicationRecord
|
||||
PostDisapproval.where("post_id in (select _.post_id from post_disapprovals _ where _.created_at < ?)", DELETION_THRESHOLD.ago).delete_all
|
||||
end
|
||||
|
||||
def self.dmail_messages!
|
||||
disapprovals = PostDisapproval.with_message.where("created_at >= ?", 1.day.ago).group_by do |pd|
|
||||
pd.post.uploader
|
||||
end
|
||||
|
||||
disapprovals.each do |uploader, list|
|
||||
message = list.map do |x|
|
||||
"* post ##{x.post_id}: #{x.message}"
|
||||
end.join("\n")
|
||||
|
||||
Dmail.create_automated(
|
||||
:to_id => uploader.id,
|
||||
:title => "Someone has commented on your uploads",
|
||||
:body => message
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
concerning :SearchMethods do
|
||||
class_methods do
|
||||
def search(params)
|
||||
|
||||
@@ -67,33 +67,6 @@ class PostDisapprovalTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "when sending dmails" do
|
||||
setup do
|
||||
@uploaders = FactoryBot.create_list(:user, 2, created_at: 2.weeks.ago)
|
||||
@disapprovers = FactoryBot.create_list(:mod_user, 2)
|
||||
|
||||
# 2 uploaders, with 2 uploads each, and 2 disapprovals on each upload.
|
||||
@uploaders.each do |uploader|
|
||||
FactoryBot.create_list(:post, 2, is_pending: true, uploader: uploader).each do |post|
|
||||
FactoryBot.create(:post_disapproval, post: post, user: @disapprovers[0])
|
||||
FactoryBot.create(:post_disapproval, post: post, user: @disapprovers[1])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
should "dmail the uploaders" do
|
||||
bot = FactoryBot.create(:user)
|
||||
User.stubs(:system).returns(bot)
|
||||
|
||||
assert_difference(["@uploaders[0].dmails.count", "@uploaders[1].dmails.count"], 1) do
|
||||
PostDisapproval.dmail_messages!
|
||||
end
|
||||
|
||||
assert(@uploaders[0].dmails.exists?(from: bot, to: @uploaders[0]))
|
||||
assert(@uploaders[1].dmails.exists?(from: bot, to: @uploaders[1]))
|
||||
end
|
||||
end
|
||||
|
||||
context "#search" do
|
||||
should "work" do
|
||||
disapproval1 = FactoryBot.create(:post_disapproval, user: @alice, post: @post_1, reason: "breaks_rules")
|
||||
|
||||
Reference in New Issue
Block a user