diff --git a/app/services/post_alerter.rb b/app/services/post_alerter.rb index 073c2ba06bd..86ecfbc2f1a 100644 --- a/app/services/post_alerter.rb +++ b/app/services/post_alerter.rb @@ -120,7 +120,7 @@ class PostAlerter .where(notification_level: TagUser.notification_levels[:watching_first_post]) .pluck(:user_id) - group_ids = post.user.groups.pluck(:id) + group_ids = topic.allowed_groups.pluck(:group_id) group_watchers = GroupUser.where(group_id: group_ids, notification_level: GroupUser.notification_levels[:watching_first_post]) .pluck(:user_id) diff --git a/spec/services/post_alerter_spec.rb b/spec/services/post_alerter_spec.rb index 4f7e2009755..e0288c4a6ee 100644 --- a/spec/services/post_alerter_spec.rb +++ b/spec/services/post_alerter_spec.rb @@ -363,6 +363,7 @@ describe PostAlerter do it "notifies the user who is following the first post group" do GroupUser.create(group_id: group.id, user_id: user.id) GroupUser.create(group_id: group.id, user_id: post.user.id) + topic.topic_allowed_groups.create(group_id: group.id) level = GroupUser.notification_levels[:watching_first_post] GroupUser.where(user_id: user.id, group_id: group.id).update_all(notification_level: level)