mirror of
https://github.com/discourse/discourse.git
synced 2025-03-26 09:26:40 +08: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
@ -89,10 +89,14 @@ module PostGuardian
|
|||||||
end
|
end
|
||||||
|
|
||||||
if is_my_own?(post)
|
if is_my_own?(post)
|
||||||
return false if post.hidden? &&
|
if post.hidden?
|
||||||
post.hidden_at.present? &&
|
return false if post.hidden_at.present? &&
|
||||||
post.hidden_at >= SiteSetting.cooldown_minutes_after_hiding_posts.minutes.ago
|
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?
|
return !post.edit_time_limit_expired?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -710,6 +710,13 @@ describe Guardian do
|
|||||||
Guardian.new(post.user).can_edit?(post).should be_true
|
Guardian.new(post.user).can_edit?(post).should be_true
|
||||||
end
|
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
|
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 = true
|
||||||
post.hidden_at = nil
|
post.hidden_at = nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user