FIX: Don't notify or return flags on system users
This commit is contained in:
parent
a7471fe85f
commit
96c59c5b82
|
@ -57,6 +57,7 @@ class PostAction < ActiveRecord::Base
|
|||
.joins(post: :topic)
|
||||
.where('posts.deleted_at' => nil)
|
||||
.where('topics.deleted_at' => nil)
|
||||
.where('posts.user_id > 0')
|
||||
.count('DISTINCT posts.id')
|
||||
|
||||
$redis.set('posts_flagged_count', posts_flagged_count)
|
||||
|
|
|
@ -114,6 +114,7 @@ module FlagQuery
|
|||
.joins("INNER JOIN posts ON posts.id = post_actions.post_id")
|
||||
.joins("INNER JOIN topics ON topics.id = posts.topic_id")
|
||||
.joins("LEFT JOIN users ON users.id = posts.user_id")
|
||||
.where("posts.user_id > 0")
|
||||
|
||||
if filter == "old"
|
||||
post_actions.where("post_actions.disagreed_at IS NOT NULL OR
|
||||
|
|
|
@ -6,6 +6,17 @@ describe FlagQuery do
|
|||
let(:codinghorror) { Fabricate(:coding_horror) }
|
||||
|
||||
describe "flagged_posts_report" do
|
||||
it "does not return flags on system posts" do
|
||||
admin = Fabricate(:admin)
|
||||
post = create_post(user: Discourse.system_user)
|
||||
PostAction.act(codinghorror, post, PostActionType.types[:spam])
|
||||
posts, topics, users = FlagQuery.flagged_posts_report(admin, "")
|
||||
|
||||
expect(posts).to be_blank
|
||||
expect(topics).to be_blank
|
||||
expect(users).to be_blank
|
||||
end
|
||||
|
||||
it "operates correctly" do
|
||||
admin = Fabricate(:admin)
|
||||
moderator = Fabricate(:moderator)
|
||||
|
|
|
@ -147,6 +147,12 @@ describe PostAction do
|
|||
expect(PostAction.flagged_posts_count).to eq(0)
|
||||
end
|
||||
|
||||
it "should ignore flags on non-human users" do
|
||||
post = create_post(user: Discourse.system_user)
|
||||
PostAction.act(codinghorror, post, PostActionType.types[:off_topic])
|
||||
expect(PostAction.flagged_posts_count).to eq(0)
|
||||
end
|
||||
|
||||
it "should ignore validated flags" do
|
||||
post = create_post
|
||||
|
||||
|
|
Loading…
Reference in New Issue