mirror of
https://github.com/discourse/discourse.git
synced 2025-03-20 19:05:31 +08:00
Add a warning when PostAlerter isn't running in sidekiq
This commit is contained in:
parent
71f66cd679
commit
bb8f0087f4
@ -130,6 +130,8 @@ class PostAlerter
|
||||
return if user_ids.blank?
|
||||
user_ids.uniq!
|
||||
|
||||
warn_if_not_sidekiq
|
||||
|
||||
# Don't notify the OP
|
||||
user_ids -= [post.user_id]
|
||||
users = User.where(id: user_ids)
|
||||
@ -485,6 +487,8 @@ class PostAlerter
|
||||
users = [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 PostAlerter
|
||||
def notify_pm_users(post, reply_to_user, notified)
|
||||
return unless post.topic
|
||||
|
||||
warn_if_not_sidekiq
|
||||
|
||||
# users that aren't part of any mentioned groups
|
||||
users = directly_targeted_users(post).reject { |u| notified.include?(u) }
|
||||
DiscourseEvent.trigger(:before_create_notifications_for_users, users, post)
|
||||
@ -523,6 +529,8 @@ class PostAlerter
|
||||
def notify_post_users(post, notified)
|
||||
return unless post.topic
|
||||
|
||||
warn_if_not_sidekiq
|
||||
|
||||
condition = <<~SQL
|
||||
id IN (
|
||||
SELECT user_id
|
||||
@ -577,4 +585,8 @@ class PostAlerter
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user