mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: topics tagged with muted tags should not be included in digest emails
This commit is contained in:
parent
fb1b119462
commit
17b51bb465
2 changed files with 25 additions and 0 deletions
|
@ -361,6 +361,13 @@ class Topic < ActiveRecord::Base
|
||||||
topics = topics.where("topics.category_id NOT IN (?)", muted_category_ids)
|
topics = topics.where("topics.category_id NOT IN (?)", muted_category_ids)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Remove muted categories
|
||||||
|
muted_tag_ids = TagUser.lookup(user, :muted).pluck(:tag_id)
|
||||||
|
unless muted_tag_ids.empty?
|
||||||
|
topics = topics.joins("LEFT OUTER JOIN topic_tags ON topic_tags.topic_id = topics.id")
|
||||||
|
.where("topic_tags.tag_id NOT IN (?)", muted_tag_ids)
|
||||||
|
end
|
||||||
|
|
||||||
topics
|
topics
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1364,6 +1364,24 @@ describe Topic do
|
||||||
expect(Topic.for_digest(u, 1.year.ago, top_order: true)).to eq([topic])
|
expect(Topic.for_digest(u, 1.year.ago, top_order: true)).to eq([topic])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't return topics with only muted tags" do
|
||||||
|
user = Fabricate(:user)
|
||||||
|
tag = Fabricate(:tag)
|
||||||
|
TagUser.change(user.id, tag.id, TagUser.notification_levels[:muted])
|
||||||
|
topic = Fabricate(:topic, tags: [tag])
|
||||||
|
|
||||||
|
expect(Topic.for_digest(user, 1.year.ago, top_order: true)).to be_blank
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns topics with both muted and not muted tags" do
|
||||||
|
user = Fabricate(:user)
|
||||||
|
muted_tag, other_tag = Fabricate(:tag), Fabricate(:tag)
|
||||||
|
TagUser.change(user.id, muted_tag.id, TagUser.notification_levels[:muted])
|
||||||
|
topic = Fabricate(:topic, tags: [muted_tag, other_tag])
|
||||||
|
|
||||||
|
expect(Topic.for_digest(user, 1.year.ago, top_order: true)).to eq([topic])
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'secured' do
|
describe 'secured' do
|
||||||
|
|
Loading…
Reference in a new issue