fixes #2461: Mod queue comments
This commit is contained in:
@@ -4,9 +4,10 @@ class PostDisapproval < ActiveRecord::Base
|
||||
belongs_to :post
|
||||
belongs_to :user
|
||||
validates_uniqueness_of :post_id, :scope => [:user_id], :message => "have already hidden this post"
|
||||
attr_accessible :post_id, :post, :user_id, :user, :reason
|
||||
attr_accessible :post_id, :post, :user_id, :user, :reason, :message
|
||||
validates_inclusion_of :reason, :in => %w(legacy breaks_rules poor_quality disinterest)
|
||||
|
||||
scope :with_message, lambda {where("message is not null and message <> ''")}
|
||||
scope :breaks_rules, lambda {where(:reason => "breaks_rules")}
|
||||
scope :poor_quality, lambda {where(:reason => "poor_quality")}
|
||||
scope :disinterest, lambda {where(:reason => ["disinterest", "legacy"])}
|
||||
@@ -15,6 +16,31 @@ class PostDisapproval < ActiveRecord::Base
|
||||
PostDisapproval.destroy_all(["created_at < ?", DELETION_THRESHOLD.ago])
|
||||
end
|
||||
|
||||
def self.dmail_messages!
|
||||
admin = User.admins.first
|
||||
disapprovals = {}
|
||||
|
||||
PostDisapproval.with_message.where("created_at >= ?", 1.year.ago).find_each do |disapproval|
|
||||
disapprovals[disapproval.user_id] ||= []
|
||||
disapprovals[disapproval.user_id] << disapproval
|
||||
end
|
||||
|
||||
disapprovals.each do |user_id, list|
|
||||
user = User.find(user_id)
|
||||
CurrentUser.scoped(admin, "127.0.0.1") do
|
||||
message = list.map do |x|
|
||||
"* post ##{x.post_id}: #{x.message}"
|
||||
end.join("\n")
|
||||
|
||||
Dmail.create_split(
|
||||
:to_id => user.id,
|
||||
:title => "Some of your uploads have been critiqued by the moderators",
|
||||
:body => message
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def create_downvote
|
||||
if %w(breaks_rules poor_quality).include?(reason)
|
||||
PostVote.create(:score => -1, :post_id => post_id)
|
||||
|
||||
Reference in New Issue
Block a user