diff --git a/lib/post_destroyer.rb b/lib/post_destroyer.rb index 28357395547..9bba2444d4f 100644 --- a/lib/post_destroyer.rb +++ b/lib/post_destroyer.rb @@ -101,9 +101,6 @@ class PostDestroyer @post.update_flagged_posts_count @post.topic_links.each(&:destroy) end - - # covered by PostRevisor - # @post.publish_change_to_clients! :revised end def user_recovered @@ -113,9 +110,6 @@ class PostDestroyer @post.revise(@user, { raw: @post.revisions.last.modifications["raw"][0] }, force_new_version: true) @post.update_flagged_posts_count end - - # covered by PostRevisor - # @post.publish_change_to_clients! :revised end diff --git a/lib/post_revisor.rb b/lib/post_revisor.rb index e100f4df0c5..cb616389b38 100644 --- a/lib/post_revisor.rb +++ b/lib/post_revisor.rb @@ -67,7 +67,7 @@ class PostRevisor publish_changes grant_badge - @post_successfully_saved && @topic_successfully_saved + successfully_saved_post_and_topic end def cleanup_whitespaces(raw) @@ -93,11 +93,7 @@ class PostRevisor end def revise_post - if should_create_new_version? - revise_and_create_new_version - else - revise - end + should_create_new_version? ? revise_and_create_new_version : revise end def should_create_new_version? @@ -178,11 +174,9 @@ class PostRevisor end def create_or_update_revision - if @version_changed - create_revision - else - update_revision - end + # don't create an empty revision if something failed + return unless successfully_saved_post_and_topic + @version_changed ? create_revision : update_revision end def create_revision @@ -305,4 +299,8 @@ class PostRevisor BadgeGranter.queue_badge_grant(Badge::Trigger::PostRevision, post: @post) end + def successfully_saved_post_and_topic + @post_successfully_saved && @topic_successfully_saved + end + end