mirror of
https://github.com/discourse/discourse.git
synced 2025-03-24 23:15:42 +08:00
FIX: mailing list mode digest emails included whispers
This commit is contained in:
parent
adb73180f7
commit
e8307ac24c
@ -69,10 +69,13 @@ class Post < ActiveRecord::Base
|
|||||||
scope :visible, -> { joins(:topic).where('topics.visible = true').where(hidden: false) }
|
scope :visible, -> { joins(:topic).where('topics.visible = true').where(hidden: false) }
|
||||||
scope :secured, lambda { |guardian| where('posts.post_type in (?)', Topic.visible_post_types(guardian && guardian.user))}
|
scope :secured, lambda { |guardian| where('posts.post_type in (?)', Topic.visible_post_types(guardian && guardian.user))}
|
||||||
scope :for_mailing_list, ->(user, since) {
|
scope :for_mailing_list, ->(user, since) {
|
||||||
created_since(since)
|
q = created_since(since)
|
||||||
.joins(:topic)
|
.joins(:topic)
|
||||||
.where(topic: Topic.for_digest(user, 100.years.ago)) # we want all topics with new content, regardless when they were created
|
.where(topic: Topic.for_digest(user, 100.years.ago)) # we want all topics with new content, regardless when they were created
|
||||||
.order('posts.created_at ASC')
|
|
||||||
|
q = q.where.not(post_type: Post.types[:whisper]) unless user.staff?
|
||||||
|
|
||||||
|
q.order('posts.created_at ASC')
|
||||||
}
|
}
|
||||||
scope :mailing_list_new_topics, ->(user, since) { for_mailing_list(user, since).where('topics.created_at > ?', since) }
|
scope :mailing_list_new_topics, ->(user, since) { for_mailing_list(user, since).where('topics.created_at > ?', since) }
|
||||||
scope :mailing_list_updates, ->(user, since) { for_mailing_list(user, since).where('topics.created_at <= ?', since) }
|
scope :mailing_list_updates, ->(user, since) { for_mailing_list(user, since).where('topics.created_at <= ?', since) }
|
||||||
|
@ -137,6 +137,21 @@ describe UserNotifications do
|
|||||||
expect(subject.subject).to match(/Try Discourse/)
|
expect(subject.subject).to match(/Try Discourse/)
|
||||||
expect(subject.subject).not_to match(/Discourse Meta/)
|
expect(subject.subject).not_to match(/Discourse Meta/)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "excludes whispers" do
|
||||||
|
new_post_in_old_topic
|
||||||
|
whisper = Fabricate(:post, topic: old_topic, created_at: 1.hour.ago, raw: "This is secret", post_type: Post.types[:whisper])
|
||||||
|
expect(subject.html_part.body.to_s).to include old_topic.title
|
||||||
|
expect(subject.html_part.body.to_s).to_not include whisper.cooked
|
||||||
|
end
|
||||||
|
|
||||||
|
it "includes whispers for staff" do
|
||||||
|
user.admin = true; user.save!
|
||||||
|
new_post_in_old_topic
|
||||||
|
whisper = Fabricate(:post, topic: old_topic, created_at: 1.hour.ago, raw: "This is secret", post_type: Post.types[:whisper])
|
||||||
|
expect(subject.html_part.body.to_s).to include old_topic.title
|
||||||
|
expect(subject.html_part.body.to_s).to include whisper.cooked
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user