A platform for community discussion. Free, open, simple.
DEV: skip topic deletion staff log when user skip new user tips.
Vinoth Kannan18f0cef72e63
diff --git a/lib/post_destroyer.rb b/lib/post_destroyer.rbindex 2ecde9a5853..23c3665ef59 100644--- a/lib/post_destroyer.rb+++ b/lib/post_destroyer.rb@@ -153,12 +153,16 @@ class PostDestroyertrash_user_actionsremove_associated_repliesremove_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))+ endend++ @post.topic.trash!(@user) if @post.topic && @post.is_first_post?update_associated_category_latest_topicupdate_user_countsTopicUser.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.ymlindex b22a53e08fd..f1ceb70cef0 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.rbindex 826d190f032..10ddf09c9d7 100644--- a/plugins/discourse-narrative-bot/plugin.rb+++ b/plugins/discourse-narrative-bot/plugin.rb@@ -194,7 +194,7 @@ after_initialize doreturn 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).destroyDiscourseNarrativeBot::Store.remove(self.id)enddiff --git a/plugins/discourse-narrative-bot/spec/user_spec.rb b/plugins/discourse-narrative-bot/spec/user_spec.rbindex bf09a0f7339..3e514cc4aee 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 doit 'should delete the existing PM' douser.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)endend