mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
FIX: do not mark post as spam if the previous flag was disagreed
This commit is contained in:
parent
0547fcf799
commit
a439500bac
2 changed files with 15 additions and 1 deletions
|
@ -655,7 +655,9 @@ class User < ActiveRecord::Base
|
||||||
# Flag all posts from a user as spam
|
# Flag all posts from a user as spam
|
||||||
def flag_linked_posts_as_spam
|
def flag_linked_posts_as_spam
|
||||||
admin = Discourse.system_user
|
admin = Discourse.system_user
|
||||||
topic_links.includes(:post).each do |tl|
|
|
||||||
|
disagreed_flag_post_ids = PostAction.where(post_action_type_id: PostActionType.types[:spam]).where.not(disagreed_at: nil).pluck(:post_id)
|
||||||
|
topic_links.includes(:post).where.not(post_id: disagreed_flag_post_ids).each do |tl|
|
||||||
begin
|
begin
|
||||||
PostAction.act(admin, tl.post, PostActionType.types[:spam], message: I18n.t('flag_reason.spam_hosts'))
|
PostAction.act(admin, tl.post, PostActionType.types[:spam], message: I18n.t('flag_reason.spam_hosts'))
|
||||||
rescue PostAction::AlreadyActed
|
rescue PostAction::AlreadyActed
|
||||||
|
|
|
@ -705,7 +705,19 @@ describe User do
|
||||||
|
|
||||||
# It doesn't raise an exception if called again
|
# It doesn't raise an exception if called again
|
||||||
user.flag_linked_posts_as_spam
|
user.flag_linked_posts_as_spam
|
||||||
|
end
|
||||||
|
|
||||||
|
it "does not flags post as spam if the previous flag for that post was disagreed" do
|
||||||
|
user.flag_linked_posts_as_spam
|
||||||
|
|
||||||
|
post.reload
|
||||||
|
expect(post.spam_count).to eq(1)
|
||||||
|
|
||||||
|
PostAction.clear_flags!(post, admin)
|
||||||
|
user.flag_linked_posts_as_spam
|
||||||
|
|
||||||
|
post.reload
|
||||||
|
expect(post.spam_count).to eq(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue