mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
FIX: Don't alert on new posts in a topic unless it's a new record
This commit is contained in:
parent
8141e1d9bc
commit
09be741820
2 changed files with 9 additions and 2 deletions
|
@ -108,7 +108,7 @@ class PostAlerter
|
||||||
|
|
||||||
sync_group_mentions(post, mentioned_groups)
|
sync_group_mentions(post, mentioned_groups)
|
||||||
|
|
||||||
if post.post_number == 1
|
if new_record && post.post_number == 1
|
||||||
topic = post.topic
|
topic = post.topic
|
||||||
|
|
||||||
if topic.present?
|
if topic.present?
|
||||||
|
|
|
@ -342,10 +342,17 @@ describe PostAlerter do
|
||||||
it "notifies the user who is following the first post category" do
|
it "notifies the user who is following the first post category" do
|
||||||
level = CategoryUser.notification_levels[:watching_first_post]
|
level = CategoryUser.notification_levels[:watching_first_post]
|
||||||
CategoryUser.set_notification_level_for_category(user, level, category.id)
|
CategoryUser.set_notification_level_for_category(user, level, category.id)
|
||||||
PostAlerter.post_created(post)
|
PostAlerter.new.after_save_post(post, true)
|
||||||
expect(user.notifications.where(notification_type: Notification.types[:watching_first_post]).count).to eq(1)
|
expect(user.notifications.where(notification_type: Notification.types[:watching_first_post]).count).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't notify when the record is not new" do
|
||||||
|
level = CategoryUser.notification_levels[:watching_first_post]
|
||||||
|
CategoryUser.set_notification_level_for_category(user, level, category.id)
|
||||||
|
PostAlerter.new.after_save_post(post, false)
|
||||||
|
expect(user.notifications.where(notification_type: Notification.types[:watching_first_post]).count).to eq(0)
|
||||||
|
end
|
||||||
|
|
||||||
it "notifies the user who is following the first post tag" do
|
it "notifies the user who is following the first post tag" do
|
||||||
level = TagUser.notification_levels[:watching_first_post]
|
level = TagUser.notification_levels[:watching_first_post]
|
||||||
TagUser.change(user.id, tag.id, level)
|
TagUser.change(user.id, tag.id, level)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue