FEATURE: silenced users should not be allowed to edit posts

This commit is contained in:
Sam 2018-08-15 14:29:36 +10:00
parent 33b5cc6bbd
commit 91e0a77a60
2 changed files with 8 additions and 0 deletions

View File

@ -147,6 +147,9 @@ module PostGuardian
end
if is_my_own?(post)
return false if @user.silenced?
if post.hidden?
return false if post.hidden_at.present? &&
post.hidden_at >= SiteSetting.cooldown_minutes_after_hiding_posts.minutes.ago

View File

@ -1174,6 +1174,11 @@ describe Guardian do
describe 'a Post' do
it 'returns false for silenced users' do
post.user.silenced_till = 1.day.from_now
expect(Guardian.new(post.user).can_edit?(post)).to be_falsey
end
it 'returns false when not logged in' do
expect(Guardian.new.can_edit?(post)).to be_falsey
end