mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: double like notification
If you got a like -> edit/quote/etc -> like you would get a double notification
This commit is contained in:
parent
0dfb9261ea
commit
5ab7f7e88d
2 changed files with 20 additions and 1 deletions
|
@ -107,7 +107,9 @@ class PostAlerter
|
|||
# Don't notify the same user about the same notification on the same post
|
||||
existing_notification = user.notifications
|
||||
.order("notifications.id desc")
|
||||
.find_by(topic_id: post.topic_id, post_number: post.post_number)
|
||||
.find_by(topic_id: post.topic_id,
|
||||
post_number: post.post_number,
|
||||
notification_type: type)
|
||||
|
||||
if existing_notification && existing_notification.notification_type == type
|
||||
return unless existing_notification.notification_type == Notification.types[:edited] &&
|
||||
|
|
|
@ -9,6 +9,23 @@ describe PostAlerter do
|
|||
PostAlerter.post_created(post)
|
||||
end
|
||||
|
||||
context 'likes' do
|
||||
it 'does not double notify users on likes' do
|
||||
ActiveRecord::Base.observers.enable :all
|
||||
|
||||
post = Fabricate(:post, raw: 'I love waffles')
|
||||
PostAction.act(evil_trout, post, PostActionType.types[:like])
|
||||
|
||||
admin = Fabricate(:admin)
|
||||
post.revise(admin, {raw: 'I made a revision'})
|
||||
|
||||
PostAction.act(admin, post, PostActionType.types[:like])
|
||||
|
||||
# one like and one edit notification
|
||||
expect(Notification.count(post_number: 1, topic_id: post.topic_id)).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
context 'quotes' do
|
||||
|
||||
it 'does not notify for muted users' do
|
||||
|
|
Loading…
Reference in a new issue