mirror of
https://github.com/discourse/discourse.git
synced 2025-04-28 06:44:34 +08:00
FIX: blocking users should never hide all posts if they are trust level 1 or higher
This commit is contained in:
parent
2d859ba0ed
commit
06eb256d0a
@ -26,6 +26,8 @@ class UserBlocker
|
|||||||
end
|
end
|
||||||
|
|
||||||
def hide_posts
|
def hide_posts
|
||||||
|
return unless @user.trust_level == TrustLevel[0]
|
||||||
|
|
||||||
Post.where(user_id: @user.id).update_all(["hidden = true, hidden_reason_id = COALESCE(hidden_reason_id, ?)", Post.hidden_reasons[:new_user_spam_threshold_reached]])
|
Post.where(user_id: @user.id).update_all(["hidden = true, hidden_reason_id = COALESCE(hidden_reason_id, ?)", Post.hidden_reasons[:new_user_spam_threshold_reached]])
|
||||||
topic_ids = Post.where(user_id: @user.id, post_number: 1).pluck(:topic_id)
|
topic_ids = Post.where(user_id: @user.id, post_number: 1).pluck(:topic_id)
|
||||||
Topic.where(id: topic_ids).update_all(visible: false) unless topic_ids.empty?
|
Topic.where(id: topic_ids).update_all(visible: false) unless topic_ids.empty?
|
||||||
|
@ -27,8 +27,6 @@ describe UserBlocker do
|
|||||||
SystemMessage.expects(:create).with(user, :blocked_by_staff).returns(true)
|
SystemMessage.expects(:create).with(user, :blocked_by_staff).returns(true)
|
||||||
UserBlocker.block(user, Fabricate.build(:admin))
|
UserBlocker.block(user, Fabricate.build(:admin))
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: it 'logs the action'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'not given a staff user argument' do
|
context 'not given a staff user argument' do
|
||||||
@ -83,12 +81,10 @@ describe UserBlocker do
|
|||||||
SystemMessage.expects(:create).never
|
SystemMessage.expects(:create).never
|
||||||
unblock_user
|
unblock_user
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: it 'logs the action'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'hide_posts' do
|
describe 'hide_posts' do
|
||||||
let(:user) { Fabricate(:user) }
|
let(:user) { Fabricate(:user, trust_level: 0) }
|
||||||
let!(:post) { Fabricate(:post, user: user) }
|
let!(:post) { Fabricate(:post, user: user) }
|
||||||
subject { UserBlocker.new(user) }
|
subject { UserBlocker.new(user) }
|
||||||
|
|
||||||
@ -101,6 +97,13 @@ describe UserBlocker do
|
|||||||
subject.block
|
subject.block
|
||||||
expect(post.topic.reload).to_not be_visible
|
expect(post.topic.reload).to_not be_visible
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't hide posts if user is TL1" do
|
||||||
|
user.trust_level = 1
|
||||||
|
subject.block
|
||||||
|
expect(post.reload).to_not be_hidden
|
||||||
|
expect(post.topic.reload).to be_visible
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user