mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
FIX: If a post has been hidden due to flagging, don't use the absolute
edit window for edit prevention.
This commit is contained in:
parent
b62aaf5a53
commit
309b67add4
2 changed files with 14 additions and 3 deletions
|
@ -89,9 +89,13 @@ module PostGuardian
|
|||
end
|
||||
|
||||
if is_my_own?(post)
|
||||
return false if post.hidden? &&
|
||||
post.hidden_at.present? &&
|
||||
post.hidden_at >= SiteSetting.cooldown_minutes_after_hiding_posts.minutes.ago
|
||||
if post.hidden?
|
||||
return false if post.hidden_at.present? &&
|
||||
post.hidden_at >= SiteSetting.cooldown_minutes_after_hiding_posts.minutes.ago
|
||||
|
||||
# If it's your own post and it's hidden, you can still edit it
|
||||
return true
|
||||
end
|
||||
|
||||
return !post.edit_time_limit_expired?
|
||||
end
|
||||
|
|
|
@ -710,6 +710,13 @@ describe Guardian do
|
|||
Guardian.new(post.user).can_edit?(post).should be_true
|
||||
end
|
||||
|
||||
it "returns true if the post is hidden, it's been enough time and the edit window has expired" do
|
||||
post.hidden = true
|
||||
post.hidden_at = (SiteSetting.cooldown_minutes_after_hiding_posts + 1).minutes.ago
|
||||
post.created_at = (SiteSetting.post_edit_time_limit + 1).minutes.ago
|
||||
Guardian.new(post.user).can_edit?(post).should be_true
|
||||
end
|
||||
|
||||
it "returns true if the post is hidden due to flagging and it's got a nil `hidden_at`" do
|
||||
post.hidden = true
|
||||
post.hidden_at = nil
|
||||
|
|
Loading…
Reference in a new issue