diff --git a/lib/post_destroyer.rb b/lib/post_destroyer.rb index 5dc04721a5d..a7cd9a11b91 100644 --- a/lib/post_destroyer.rb +++ b/lib/post_destroyer.rb @@ -110,6 +110,7 @@ class PostDestroyer UserActionManager.post_created(@post) DiscourseEvent.trigger(:post_recovered, @post, @opts, @user) Jobs.enqueue(:sync_topic_user_bookmarked, topic_id: topic.id) if topic + Jobs.enqueue(:notify_mailing_list_subscribers, post_id: @post.id) if @post.is_first_post? UserActionManager.topic_created(topic) diff --git a/spec/lib/post_destroyer_spec.rb b/spec/lib/post_destroyer_spec.rb index 20a18a3e829..25fa3496dd8 100644 --- a/spec/lib/post_destroyer_spec.rb +++ b/spec/lib/post_destroyer_spec.rb @@ -1201,4 +1201,26 @@ RSpec.describe PostDestroyer do ) end end + + describe "mailing_list_mode emails on recovery" do + fab!(:topic) { Fabricate(:topic) } + fab!(:post_1) { Fabricate(:post, topic: topic) } + fab!(:post_2) { Fabricate(:post, topic: topic) } + + it "enqueues the notify_mailing_list_subscribers_job for the post" do + PostDestroyer.new(admin, post_2).destroy + post_2.reload + expect_enqueued_with(job: :notify_mailing_list_subscribers, args: { post_id: post_2.id }) do + PostDestroyer.new(admin, post_2).recover + end + end + + it "enqueues the notify_mailing_list_subscribers_job for the op" do + PostDestroyer.new(admin, post_1).destroy + post_1.reload + expect_enqueued_with(job: :notify_mailing_list_subscribers, args: { post_id: post_1.id }) do + PostDestroyer.new(admin, post_1).recover + end + end + end end