Skip to content

Commit

Permalink
FIX: exclude suppressed category topics in digest even if unmuted. (#…
Browse files Browse the repository at this point in the history
…14793)

Previously, suppressed category topics are included in the digest emails if the user visited that topic before and the `TopicUser` record is created with any notification level except 'muted'.
  • Loading branch information
vinothkannans committed Nov 3, 2021
1 parent 3254d35 commit 53b7220
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/topic.rb
Expand Up @@ -511,7 +511,7 @@ def self.for_digest(user, since, opts = nil)
# Remove muted and shared draft categories
remove_category_ids = CategoryUser.where(user_id: user.id, notification_level: CategoryUser.notification_levels[:muted]).pluck(:category_id)
if SiteSetting.digest_suppress_categories.present?
remove_category_ids += SiteSetting.digest_suppress_categories.split("|").map(&:to_i)
topics = topics.where("topics.category_id NOT IN (?)", SiteSetting.digest_suppress_categories.split("|").map(&:to_i))
end
if SiteSetting.shared_drafts_enabled?
remove_category_ids << SiteSetting.shared_drafts_category
Expand Down
6 changes: 5 additions & 1 deletion spec/models/topic_spec.rb
Expand Up @@ -2071,11 +2071,15 @@ def set_state!(group, user, state)
it "doesn't return topics from suppressed categories" do
user = Fabricate(:user)
category = Fabricate(:category_with_definition, created_at: 2.minutes.ago)
Fabricate(:topic, category: category, created_at: 1.minute.ago)
topic = Fabricate(:topic, category: category, created_at: 1.minute.ago)

SiteSetting.digest_suppress_categories = "#{category.id}"

expect(Topic.for_digest(user, 1.year.ago, top_order: true)).to be_blank

Fabricate(:topic_user, user: user, topic: topic, notification_level: TopicUser.notification_levels[:regular])

expect(Topic.for_digest(user, 1.year.ago, top_order: true)).to be_blank
end

it "doesn't return topics from TL0 users" do
Expand Down

0 comments on commit 53b7220

Please sign in to comment.