mirror of
https://github.com/discourse/discourse.git
synced 2025-03-27 14:25:36 +08:00
FEATURE: Digest suppression by tags (#23089)
* FEATURE: Digest suppression by tags * fixed stree issues * fixed code so untagged topics are not suppressed when suppressing certain tags
This commit is contained in:
parent
3d86fc1391
commit
477a5dd371
@ -585,6 +585,13 @@ class Topic < ActiveRecord::Base
|
||||
SiteSetting.digest_suppress_categories.split("|").map(&:to_i),
|
||||
)
|
||||
end
|
||||
if SiteSetting.digest_suppress_tags.present?
|
||||
topics =
|
||||
topics.joins("LEFT JOIN topic_tags tg ON topics.id = tg.topic_id").where(
|
||||
"tg.tag_id NOT IN (?) OR tg.tag_id IS NULL",
|
||||
SiteSetting.digest_suppress_tags.split("|").map(&:to_i),
|
||||
)
|
||||
end
|
||||
remove_category_ids << SiteSetting.shared_drafts_category if SiteSetting.shared_drafts_enabled?
|
||||
if remove_category_ids.present?
|
||||
remove_category_ids.uniq!
|
||||
|
@ -2149,6 +2149,7 @@ en:
|
||||
digest_min_excerpt_length: "Minimum post excerpt in the email summary, in characters."
|
||||
suppress_digest_email_after_days: "Suppress summary emails for users not seen on the site for more than (n) days."
|
||||
digest_suppress_categories: "Suppress these categories from summary emails."
|
||||
digest_suppress_tags: "Suppress these tags from summary emails."
|
||||
disable_digest_emails: "Disable summary emails for all users."
|
||||
apply_custom_styles_to_digest: "Custom email template and css are applied to summary emails."
|
||||
email_accent_bg_color: "The accent color to be used as the background of some elements in HTML emails. Enter a color name ('red') or hex value ('#FF0000')."
|
||||
|
@ -1156,6 +1156,9 @@ email:
|
||||
digest_suppress_categories:
|
||||
type: category_list
|
||||
default: ""
|
||||
digest_suppress_tags:
|
||||
type: tag_list
|
||||
default: ""
|
||||
disable_digest_emails:
|
||||
default: false
|
||||
client: true
|
||||
|
@ -2363,6 +2363,27 @@ RSpec.describe Topic do
|
||||
expect(Topic.for_digest(user, 1.year.ago, top_order: true)).to be_blank
|
||||
end
|
||||
|
||||
it "doesn't return topics from suppressed tags" do
|
||||
category = Fabricate(:category_with_definition, created_at: 2.minutes.ago)
|
||||
topic = Fabricate(:topic, category: category, created_at: 1.minute.ago)
|
||||
topic2 = Fabricate(:topic, category: category, created_at: 1.minute.ago)
|
||||
tag = Fabricate(:tag)
|
||||
Fabricate(:topic_tag, topic: topic, tag: tag)
|
||||
|
||||
SiteSetting.digest_suppress_tags = "#{tag.id}"
|
||||
topics = Topic.for_digest(user, 1.year.ago, top_order: true)
|
||||
expect(topics).to eq([topic2])
|
||||
|
||||
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 eq([topic2])
|
||||
end
|
||||
|
||||
it "doesn't return topics from TL0 users" do
|
||||
new_user = Fabricate(:user, trust_level: 0)
|
||||
Fabricate(:topic, user: new_user, created_at: 1.minute.ago)
|
||||
|
Loading…
x
Reference in New Issue
Block a user