FIX: Notify mailing list subscribers on category change (#28811)

cf. https://meta.discourse.org/t/email-notifications-dont-get-sent-on-category-change-for-mailing-list-mode-users/308096
This commit is contained in:
Yuvaraj J 2024-10-11 18:17:39 +05:30 committed by GitHub
parent 79d2eb5beb
commit 65a1e149ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 0 deletions

View File

@ -13,6 +13,7 @@ module Jobs
include_tag_watchers: false,
)
post_alerter.notify_first_post_watchers(post, post_alerter.category_watchers(post.topic))
::Jobs.enqueue(:notify_mailing_list_subscribers, post_id: post.id)
end
end
end

View File

@ -19,4 +19,18 @@ RSpec.describe ::Jobs::NotifyCategoryChange do
Notification.count
}
end
context "when mailing list mode is enabled" do
before { SiteSetting.disable_mailing_list_mode = false }
before { regular_user.user_option.update(mailing_list_mode: true, mailing_list_mode_frequency: 1) }
before { Jobs.run_immediately! }
it "notifies mailing list subscribers" do
post.topic.update!(category: category)
expected_args = { "post_id" => post.id, "current_site_id" => "default" }
Jobs::NotifyMailingListSubscribers.any_instance.expects(:execute).with(expected_args).once
described_class.new.execute(post_id: post.id, notified_user_ids: [])
end
end
end