FEATURE: auto-delete any hidden posts that stay hidden for more than 30 days

This commit is contained in:
Régis Hanol
2014-09-25 19:51:00 +02:00
parent b16e6f8289
commit 69400a802f
6 changed files with 64 additions and 3 deletions

View File

@@ -404,7 +404,7 @@ class PostAction < ActiveRecord::Base
reason = guess_hide_reason(old_flags)
end
Post.where(id: post.id).update_all(["hidden = true, hidden_at = CURRENT_TIMESTAMP, hidden_reason_id = COALESCE(hidden_reason_id, ?)", reason])
Post.where(id: post.id).update_all(["hidden = true, hidden_at = ?, hidden_reason_id = COALESCE(hidden_reason_id, ?)", Time.now, reason])
Topic.where("id = :topic_id AND NOT EXISTS(SELECT 1 FROM POSTS WHERE topic_id = :topic_id AND NOT hidden)", topic_id: post.topic_id).update_all(visible: false)
# inform user