DEV: skip topic deletion staff log when user skip new user tips.

DEV: skip topic deletion staff log when user skip new user tips.

Previously, every time when a user skipped the “new user tips” it will add a staff action log since the discobot’s welcome post is destroyed.

diff --git a/lib/post_destroyer.rb b/lib/post_destroyer.rb
index 2ecde9a..23c3665 100644
--- a/lib/post_destroyer.rb
+++ b/lib/post_destroyer.rb
@@ -153,12 +153,16 @@ class PostDestroyer
       trash_user_actions
       remove_associated_replies
       remove_associated_notifications
-      if @post.topic && @post.is_first_post?
-        StaffActionLogger.new(@user).log_topic_delete_recover(@post.topic, "delete_topic", @opts.slice(:context)) if @user.id != @post.user_id
-        @post.topic.trash!(@user)
-      elsif @user.id != @post.user_id
-        StaffActionLogger.new(@user).log_post_deletion(@post, @opts.slice(:context))
+
+      if @user.id != @post.user_id && !@opts[:skip_staff_log]
+        if @post.topic && @post.is_first_post?
+          StaffActionLogger.new(@user).log_topic_delete_recover(@post.topic, "delete_topic", @opts.slice(:context))
+        else
+          StaffActionLogger.new(@user).log_post_deletion(@post, @opts.slice(:context))
+        end
       end
+
+      @post.topic.trash!(@user) if @post.topic && @post.is_first_post?
       update_associated_category_latest_topic
       update_user_counts
       TopicUser.update_post_action_cache(post_id: @post.id)
diff --git a/plugins/discourse-narrative-bot/config/locales/server.en.yml b/plugins/discourse-narrative-bot/config/locales/server.en.yml
index b22a53e..f1ceb70 100644
--- a/plugins/discourse-narrative-bot/config/locales/server.en.yml
+++ b/plugins/discourse-narrative-bot/config/locales/server.en.yml
@@ -154,7 +154,6 @@ en:
       reset_trigger: "tutorial"
       title: "New user tutorial completion certificate"
       cert_title: "In recognition of successful completion of the new user tutorial"
-      delete_reason: "User skipped the new user tips"
 
       hello:
         title: "Greetings!"
diff --git a/plugins/discourse-narrative-bot/plugin.rb b/plugins/discourse-narrative-bot/plugin.rb
index 826d190..10ddf09 100644
--- a/plugins/discourse-narrative-bot/plugin.rb
+++ b/plugins/discourse-narrative-bot/plugin.rb
@@ -194,7 +194,7 @@ after_initialize do
     return if topic.blank?
 
     first_post = topic.ordered_posts.first
-    PostDestroyer.new(Discourse.system_user, first_post, context: I18n.t('discourse_narrative_bot.new_user_narrative.delete_reason')).destroy
+    PostDestroyer.new(Discourse.system_user, first_post, skip_staff_log: true).destroy
     DiscourseNarrativeBot::Store.remove(self.id)
   end
 
diff --git a/plugins/discourse-narrative-bot/spec/user_spec.rb b/plugins/discourse-narrative-bot/spec/user_spec.rb
index bf09a0f..3e514cc 100644
--- a/plugins/discourse-narrative-bot/spec/user_spec.rb
+++ b/plugins/discourse-narrative-bot/spec/user_spec.rb
@@ -119,7 +119,10 @@ describe User do
       it 'should delete the existing PM' do
         user.user_option.skip_new_user_tips = true
 
-        expect { user.user_option.save! }.to change { Topic.count }.by(-1)
+        expect {
+          user.user_option.save!
+        }.to change { Topic.count }.by(-1)
+          .and change { UserHistory.count }.by(0)
       end
     end
 

GitHub sha: 18f0cef7