FEATURE: site setting for suppressing categories from digest email
This commit is contained in:
parent
27c793a990
commit
64feffbb60
|
@ -339,6 +339,10 @@ class Topic < ActiveRecord::Base
|
||||||
|
|
||||||
# Remove muted categories
|
# Remove muted categories
|
||||||
muted_category_ids = CategoryUser.where(user_id: user.id, notification_level: CategoryUser.notification_levels[:muted]).pluck(:category_id)
|
muted_category_ids = CategoryUser.where(user_id: user.id, notification_level: CategoryUser.notification_levels[:muted]).pluck(:category_id)
|
||||||
|
if SiteSetting.digest_suppress_categories.present?
|
||||||
|
muted_category_ids += SiteSetting.digest_suppress_categories.split("|").map(&:to_i)
|
||||||
|
muted_category_ids = muted_category_ids.uniq
|
||||||
|
end
|
||||||
if muted_category_ids.present?
|
if muted_category_ids.present?
|
||||||
topics = topics.where("topics.category_id NOT IN (?)", muted_category_ids)
|
topics = topics.where("topics.category_id NOT IN (?)", muted_category_ids)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1195,6 +1195,7 @@ en:
|
||||||
digest_topics: "The maximum number of topics to display in the email digest."
|
digest_topics: "The maximum number of topics to display in the email digest."
|
||||||
digest_min_excerpt_length: "Minimum post excerpt in the email digest, in characters."
|
digest_min_excerpt_length: "Minimum post excerpt in the email digest, in characters."
|
||||||
delete_digest_email_after_days: "Suppress digest emails for users not seen on the site for more than (n) days."
|
delete_digest_email_after_days: "Suppress digest emails for users not seen on the site for more than (n) days."
|
||||||
|
digest_suppress_categories: "Suppress these categories from digest emails."
|
||||||
disable_digest_emails: "Disable digest emails for all users."
|
disable_digest_emails: "Disable digest emails for all users."
|
||||||
|
|
||||||
detect_custom_avatars: "Whether or not to check that users have uploaded custom profile pictures."
|
detect_custom_avatars: "Whether or not to check that users have uploaded custom profile pictures."
|
||||||
|
|
|
@ -512,6 +512,9 @@ email:
|
||||||
digest_min_excerpt_length: 100
|
digest_min_excerpt_length: 100
|
||||||
digest_topics: 20
|
digest_topics: 20
|
||||||
delete_digest_email_after_days: 365
|
delete_digest_email_after_days: 365
|
||||||
|
digest_suppress_categories:
|
||||||
|
type: category_list
|
||||||
|
default: ''
|
||||||
disable_digest_emails:
|
disable_digest_emails:
|
||||||
default: false
|
default: false
|
||||||
client: true
|
client: true
|
||||||
|
|
|
@ -1296,6 +1296,16 @@ describe Topic do
|
||||||
expect(Topic.for_digest(user, 1.year.ago, top_order: true)).to be_blank
|
expect(Topic.for_digest(user, 1.year.ago, top_order: true)).to be_blank
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't return topics from suppressed categories" do
|
||||||
|
user = Fabricate(:user)
|
||||||
|
category = Fabricate(:category)
|
||||||
|
Fabricate(:topic, category: category)
|
||||||
|
|
||||||
|
SiteSetting.digest_suppress_categories = "#{category.id}"
|
||||||
|
|
||||||
|
expect(Topic.for_digest(user, 1.year.ago, top_order: true)).to be_blank
|
||||||
|
end
|
||||||
|
|
||||||
it "doesn't return topics from TL0 users" do
|
it "doesn't return topics from TL0 users" do
|
||||||
new_user = Fabricate(:user, trust_level: 0)
|
new_user = Fabricate(:user, trust_level: 0)
|
||||||
Fabricate(:topic, user_id: new_user.id)
|
Fabricate(:topic, user_id: new_user.id)
|
||||||
|
@ -1607,7 +1617,7 @@ describe Topic do
|
||||||
|
|
||||||
topic.update_status('closed', true, user)
|
topic.update_status('closed', true, user)
|
||||||
topic.reload
|
topic.reload
|
||||||
|
|
||||||
expect(@topic_status_event_triggered).to eq(true)
|
expect(@topic_status_event_triggered).to eq(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue