SECURITY: Unread post notifications should respect whispers
This commit is contained in:
parent
32bc9a8f93
commit
eacd75bcf8
|
@ -51,7 +51,8 @@ class PostAlerter
|
|||
end
|
||||
|
||||
def unread_posts(user, topic)
|
||||
Post.where('post_number > COALESCE((
|
||||
Post.secured(Guardian.new(user))
|
||||
.where('post_number > COALESCE((
|
||||
SELECT last_read_post_number FROM topic_users tu
|
||||
WHERE tu.user_id = ? AND tu.topic_id = ? ),0)',
|
||||
user.id, topic.id)
|
||||
|
|
|
@ -9,6 +9,20 @@ describe PostAlerter do
|
|||
PostAlerter.post_created(post)
|
||||
end
|
||||
|
||||
context "unread" do
|
||||
it "does not return whispers as unread posts" do
|
||||
op = Fabricate(:post)
|
||||
whisper = Fabricate(:post, raw: 'this is a whisper post',
|
||||
user: Fabricate(:admin),
|
||||
topic: op.topic,
|
||||
reply_to_post_number: op.post_number,
|
||||
post_type: Post.types[:whisper])
|
||||
|
||||
|
||||
expect(PostAlerter.new.first_unread_post(op.user, op.topic)).to be_blank
|
||||
end
|
||||
end
|
||||
|
||||
context 'likes' do
|
||||
it 'does not double notify users on likes' do
|
||||
ActiveRecord::Base.observers.enable :all
|
||||
|
|
Loading…
Reference in New Issue