Record when a post was hidden
This commit is contained in:
parent
533244f39d
commit
3811efa5e2
|
@ -307,7 +307,7 @@ class PostAction < ActiveRecord::Base
|
||||||
reason = guess_hide_reason(old_flags)
|
reason = guess_hide_reason(old_flags)
|
||||||
end
|
end
|
||||||
|
|
||||||
Post.where(id: post.id).update_all(["hidden = true, hidden_reason_id = COALESCE(hidden_reason_id, ?)", reason])
|
Post.where(id: post.id).update_all(["hidden = true, hidden_at = CURRENT_TIMESTAMP, hidden_reason_id = COALESCE(hidden_reason_id, ?)", reason])
|
||||||
Topic.where(["id = :topic_id AND NOT EXISTS(SELECT 1 FROM POSTS WHERE topic_id = :topic_id AND NOT hidden)",
|
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 })
|
topic_id: post.topic_id]).update_all({ visible: false })
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddHiddenAtToPosts < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :posts, :hidden_at, :timestamp
|
||||||
|
end
|
||||||
|
end
|
|
@ -100,6 +100,7 @@ class PostRevisor
|
||||||
if @editor == @post.user && @post.hidden && @post.hidden_reason_id == Post.hidden_reasons[:flag_threshold_reached]
|
if @editor == @post.user && @post.hidden && @post.hidden_reason_id == Post.hidden_reasons[:flag_threshold_reached]
|
||||||
@post.hidden = false
|
@post.hidden = false
|
||||||
@post.hidden_reason_id = nil
|
@post.hidden_reason_id = nil
|
||||||
|
@post.hidden_at = nil
|
||||||
@post.topic.update_attributes(visible: true)
|
@post.topic.update_attributes(visible: true)
|
||||||
|
|
||||||
PostAction.clear_flags!(@post, -1)
|
PostAction.clear_flags!(@post, -1)
|
||||||
|
|
|
@ -98,14 +98,17 @@ describe PostAction do
|
||||||
admin = Fabricate(:admin)
|
admin = Fabricate(:admin)
|
||||||
PostAction.act(codinghorror, post, PostActionType.types[:off_topic])
|
PostAction.act(codinghorror, post, PostActionType.types[:off_topic])
|
||||||
post.hidden.should be_false
|
post.hidden.should be_false
|
||||||
|
post.hidden_at.should be_blank
|
||||||
PostAction.defer_flags!(post, admin.id)
|
PostAction.defer_flags!(post, admin.id)
|
||||||
PostAction.flagged_posts_count.should == 0
|
PostAction.flagged_posts_count.should == 0
|
||||||
post.reload
|
post.reload
|
||||||
post.hidden.should be_false
|
post.hidden.should be_false
|
||||||
|
post.hidden_at.should be_blank
|
||||||
|
|
||||||
PostAction.hide_post!(post, PostActionType.types[:off_topic])
|
PostAction.hide_post!(post, PostActionType.types[:off_topic])
|
||||||
post.reload
|
post.reload
|
||||||
post.hidden.should be_true
|
post.hidden.should be_true
|
||||||
|
post.hidden_at.should be_present
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -253,6 +256,7 @@ describe PostAction do
|
||||||
|
|
||||||
post.hidden.should.should be_true
|
post.hidden.should.should be_true
|
||||||
post.hidden_reason_id.should == Post.hidden_reasons[:flag_threshold_reached]
|
post.hidden_reason_id.should == Post.hidden_reasons[:flag_threshold_reached]
|
||||||
|
post.hidden_at.should be_present
|
||||||
post.topic.visible.should be_false
|
post.topic.visible.should be_false
|
||||||
|
|
||||||
post.revise(post.user, post.raw + " ha I edited it ")
|
post.revise(post.user, post.raw + " ha I edited it ")
|
||||||
|
@ -260,6 +264,7 @@ describe PostAction do
|
||||||
|
|
||||||
post.hidden.should be_false
|
post.hidden.should be_false
|
||||||
post.hidden_reason_id.should be_nil
|
post.hidden_reason_id.should be_nil
|
||||||
|
post.hidden_at.should be_blank
|
||||||
post.topic.visible.should be_true
|
post.topic.visible.should be_true
|
||||||
|
|
||||||
PostAction.act(u1, post, PostActionType.types[:spam])
|
PostAction.act(u1, post, PostActionType.types[:spam])
|
||||||
|
@ -269,12 +274,14 @@ describe PostAction do
|
||||||
|
|
||||||
post.hidden.should be_true
|
post.hidden.should be_true
|
||||||
post.hidden_reason_id.should == Post.hidden_reasons[:flag_threshold_reached_again]
|
post.hidden_reason_id.should == Post.hidden_reasons[:flag_threshold_reached_again]
|
||||||
|
post.hidden_at.should be_true
|
||||||
|
|
||||||
post.revise(post.user, post.raw + " ha I edited it again ")
|
post.revise(post.user, post.raw + " ha I edited it again ")
|
||||||
|
|
||||||
post.reload
|
post.reload
|
||||||
|
|
||||||
post.hidden.should be_true
|
post.hidden.should be_true
|
||||||
|
post.hidden_at.should be_true
|
||||||
post.hidden_reason_id.should == Post.hidden_reasons[:flag_threshold_reached_again]
|
post.hidden_reason_id.should == Post.hidden_reasons[:flag_threshold_reached_again]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue