FIX: Exclude shared drafts from digests
This commit is contained in:
parent
1bef008a1e
commit
6da7a97eee
|
@ -509,14 +509,17 @@ class Topic < ActiveRecord::Base
|
||||||
topics = topics.where("topics.id NOT IN (?)", category_topic_ids)
|
topics = topics.where("topics.id NOT IN (?)", category_topic_ids)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Remove muted categories
|
# Remove muted and shared draft categories
|
||||||
muted_category_ids = CategoryUser.where(user_id: user.id, notification_level: CategoryUser.notification_levels[:muted]).pluck(:category_id)
|
remove_category_ids = CategoryUser.where(user_id: user.id, notification_level: CategoryUser.notification_levels[:muted]).pluck(:category_id)
|
||||||
if SiteSetting.digest_suppress_categories.present?
|
if SiteSetting.digest_suppress_categories.present?
|
||||||
muted_category_ids += SiteSetting.digest_suppress_categories.split("|").map(&:to_i)
|
remove_category_ids += SiteSetting.digest_suppress_categories.split("|").map(&:to_i)
|
||||||
muted_category_ids = muted_category_ids.uniq
|
|
||||||
end
|
end
|
||||||
if muted_category_ids.present?
|
if SiteSetting.shared_drafts_category.present?
|
||||||
topics = topics.where("topics.category_id NOT IN (?)", muted_category_ids)
|
remove_category_ids << SiteSetting.shared_drafts_enabled?
|
||||||
|
end
|
||||||
|
if remove_category_ids.present?
|
||||||
|
remove_category_ids.uniq!
|
||||||
|
topics = topics.where("topics.category_id NOT IN (?)", remove_category_ids)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Remove muted tags
|
# Remove muted tags
|
||||||
|
|
|
@ -174,6 +174,23 @@ describe UserNotifications do
|
||||||
expect(html).to_not include post.raw
|
expect(html).to_not include post.raw
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "excludes shared drafts" do
|
||||||
|
cat = Fabricate(:category)
|
||||||
|
SiteSetting.shared_drafts_category = cat.id
|
||||||
|
topic = Fabricate(:topic, title: "This is a draft", category_id: cat.id, created_at: 1.hour.ago)
|
||||||
|
post = Fabricate(
|
||||||
|
:post,
|
||||||
|
topic: topic,
|
||||||
|
score: 100.0,
|
||||||
|
post_number: 2,
|
||||||
|
raw: "secret draft content",
|
||||||
|
created_at: 1.hour.ago
|
||||||
|
)
|
||||||
|
html = subject.html_part.body.to_s
|
||||||
|
expect(html).to_not include topic.title
|
||||||
|
expect(html).to_not include post.raw
|
||||||
|
end
|
||||||
|
|
||||||
it "excludes whispers and other post types that don't belong" do
|
it "excludes whispers and other post types that don't belong" do
|
||||||
t = Fabricate(:topic, user: Fabricate(:user), title: "Who likes the same stuff I like?", created_at: 1.hour.ago)
|
t = Fabricate(:topic, user: Fabricate(:user), title: "Who likes the same stuff I like?", created_at: 1.hour.ago)
|
||||||
whisper = Fabricate(:post, topic: t, score: 100.0, post_number: 2, raw: "You like weird stuff", post_type: Post.types[:whisper], created_at: 1.hour.ago)
|
whisper = Fabricate(:post, topic: t, score: 100.0, post_number: 2, raw: "You like weird stuff", post_type: Post.types[:whisper], created_at: 1.hour.ago)
|
||||||
|
|
Loading…
Reference in New Issue