mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 02:13:39 +08:00
FIX: If a user deletes a hidden post, it should not lose history
This commit is contained in:
parent
0e26c57afa
commit
0d84c5b894
|
@ -179,7 +179,8 @@ class PostDestroyer
|
||||||
key = @post.is_first_post? ? 'js.topic.deleted_by_author' : 'js.post.deleted_by_author'
|
key = @post.is_first_post? ? 'js.topic.deleted_by_author' : 'js.post.deleted_by_author'
|
||||||
@post.revise(@user,
|
@post.revise(@user,
|
||||||
{ raw: I18n.t(key, count: delete_removed_posts_after) },
|
{ raw: I18n.t(key, count: delete_removed_posts_after) },
|
||||||
force_new_version: true
|
force_new_version: true,
|
||||||
|
deleting_post: true
|
||||||
)
|
)
|
||||||
|
|
||||||
Post.transaction do
|
Post.transaction do
|
||||||
|
|
|
@ -407,6 +407,7 @@ class PostRevisor
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_flags_and_unhide_post
|
def remove_flags_and_unhide_post
|
||||||
|
return if @opts[:deleting_post]
|
||||||
return unless editing_a_flagged_and_hidden_post?
|
return unless editing_a_flagged_and_hidden_post?
|
||||||
|
|
||||||
flaggers = []
|
flaggers = []
|
||||||
|
|
|
@ -345,6 +345,12 @@ describe PostDestroyer do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "maintains history when a user destroys a hidden post" do
|
||||||
|
post.hide!(PostActionType.types[:inappropriate])
|
||||||
|
PostDestroyer.new(post.user, post).destroy
|
||||||
|
expect(post.revisions[0].modifications['raw']).to be_present
|
||||||
|
end
|
||||||
|
|
||||||
it "when topic is destroyed, it updates user_stats correctly" do
|
it "when topic is destroyed, it updates user_stats correctly" do
|
||||||
SiteSetting.min_topic_title_length = 5
|
SiteSetting.min_topic_title_length = 5
|
||||||
post.topic.update_column(:title, "xyz")
|
post.topic.update_column(:title, "xyz")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user