A platform for community discussion. Free, open, simple.
FIX: when tag or category is added notify users that topic was modified (#8750)
Krzysztof Kotlarek0420be88a642
diff --git a/app/jobs/regular/notify_category_change.rb b/app/jobs/regular/notify_category_change.rbindex fbad7582e4a..d6bf0dc0c2c 100644--- a/app/jobs/regular/notify_category_change.rb+++ b/app/jobs/regular/notify_category_change.rb@@ -7,7 +7,7 @@ module Jobsif post&.topic&.visible?post_alerter = PostAlerter.new- post_alerter.notify_post_users(post, User.where(id: args[:notified_user_ids]), include_tag_watchers: false)+ post_alerter.notify_post_users(post, User.where(id: args[:notified_user_ids]), include_tag_watchers: false, new_record: false)post_alerter.notify_first_post_watchers(post, post_alerter.category_watchers(post.topic))endenddiff --git a/app/jobs/regular/notify_tag_change.rb b/app/jobs/regular/notify_tag_change.rbindex dff6769de97..d88deaf965c 100644--- a/app/jobs/regular/notify_tag_change.rb+++ b/app/jobs/regular/notify_tag_change.rb@@ -7,7 +7,7 @@ module Jobsif post&.topic&.visible?post_alerter = PostAlerter.new- post_alerter.notify_post_users(post, User.where(id: args[:notified_user_ids]), include_category_watchers: false)+ post_alerter.notify_post_users(post, User.where(id: args[:notified_user_ids]), include_category_watchers: false, new_record: false)post_alerter.notify_first_post_watchers(post, post_alerter.tag_watchers(post.topic))endenddiff --git a/app/services/post_alerter.rb b/app/services/post_alerter.rbindex 379c5b97741..6fc26df6d3a 100644--- a/app/services/post_alerter.rb+++ b/app/services/post_alerter.rb@@ -550,7 +550,7 @@ class PostAlerterendend- def notify_post_users(post, notified, include_category_watchers: true, include_tag_watchers: true)+ def notify_post_users(post, notified, include_category_watchers: true, include_tag_watchers: true, new_record: true)return unless post.topicwarn_if_not_sidekiq@@ -607,9 +607,12 @@ class PostAlerternotify = notify.where("id NOT IN (?)", exclude_user_ids) if exclude_user_ids.present?DiscourseEvent.trigger(:before_create_notifications_for_users, notify, post)++ notification_type = new_record ? Notification.types[:posted] : Notification.types[:edited]+notify.pluck(:id).each do |user_id|user = User.find_by(id: user_id)- create_notification(user, Notification.types[:posted], post)+ create_notification(user, notification_type, post)endenddiff --git a/spec/jobs/notify_tag_change_spec.rb b/spec/jobs/notify_tag_change_spec.rbindex 9d6e0053e3a..ee96235e2e7 100644--- a/spec/jobs/notify_tag_change_spec.rb+++ b/spec/jobs/notify_tag_change_spec.rb@@ -24,6 +24,7 @@ describe ::Jobs::NotifyTagChange donotification = Notification.lastexpect(notification.user_id).to eq(user.id)expect(notification.topic_id).to eq(post.topic_id)+ expect(notification.notification_type).to eq(Notification.types[:edited])endit 'doesnt create notification for user watching category' dodiff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rbindex 6b1d7a070cb..8d320412817 100644--- a/spec/models/topic_spec.rb+++ b/spec/models/topic_spec.rb@@ -1404,7 +1404,7 @@ describe Topic douser_id: user.id,topic_id: topic.id,post_number: 1,- notification_type: Notification.types[:posted]+ notification_type: Notification.types[:edited]).exists?).to eq(true)expect(Notification.where(