A platform for community discussion. Free, open, simple.
Add a warning when PostAlerter isn't running in sidekiq
Régis Hanolbb8f0087f417
diff --git a/app/services/post_alerter.rb b/app/services/post_alerter.rbindex f05754357d3..3f151f875cb 100644--- a/app/services/post_alerter.rb+++ b/app/services/post_alerter.rb@@ -130,6 +130,8 @@ class PostAlerterreturn if user_ids.blank?user_ids.uniq!+ warn_if_not_sidekiq+# Don't notify the OPuser_ids -= [post.user_id]users = User.where(id: user_ids)@@ -485,6 +487,8 @@ class PostAlerterusers = [users] unless users.is_a?(Array)users = users.reject { |u| u.staged? } if post.topic&.private_message?+ warn_if_not_sidekiq+DiscourseEvent.trigger(:before_create_notifications_for_users, users, post)users.each do |u|create_notification(u, Notification.types[type], post, opts)@@ -496,6 +500,8 @@ class PostAlerterdef notify_pm_users(post, reply_to_user, notified)return unless post.topic+ warn_if_not_sidekiq+# users that aren't part of any mentioned groupsusers = directly_targeted_users(post).reject { |u| notified.include?(u) }DiscourseEvent.trigger(:before_create_notifications_for_users, users, post)@@ -523,6 +529,8 @@ class PostAlerterdef notify_post_users(post, notified)return unless post.topic+ warn_if_not_sidekiq+condition = <<~SQLid IN (SELECT user_id@@ -577,4 +585,8 @@ class PostAlerterendend+ def warn_if_not_sidekiq+ Rails.logger.warn("PostAlerter.#{caller_locations(1, 1)[0].label} was called outside of sidekiq") unless Sidekiq.server?+ end+end