From 0a58b1897098eb14f9f3b2ab7bc5329195220888 Mon Sep 17 00:00:00 2001 From: Mark VanLandingham Date: Thu, 29 Feb 2024 08:33:38 -0600 Subject: [PATCH] DEV: Move DiscourseEvent trigger in PostAlerter#push_notification (#25931) --- app/services/post_alerter.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/services/post_alerter.rb b/app/services/post_alerter.rb index 08b833e90ed..a1755ad3b6d 100644 --- a/app/services/post_alerter.rb +++ b/app/services/post_alerter.rb @@ -57,6 +57,11 @@ class PostAlerter def self.push_notification(user, payload) return if user.do_not_disturb? + # This DiscourseEvent needs to be independent of the push_notification_filters for some use cases. + # If the subscriber of this event wants to filter usage by push_notification_filters as well, + # implement same logic as below (`if DiscoursePluginRegistry.push_notification_filters.any?...`) + DiscourseEvent.trigger(:push_notification, user, payload) + if DiscoursePluginRegistry.push_notification_filters.any? { |filter| !filter.call(user, payload) } @@ -90,8 +95,6 @@ class PostAlerter Jobs.enqueue(:push_notification, clients: clients, payload: payload, user_id: user.id) end end - - DiscourseEvent.trigger(:push_notification, user, payload) end def initialize(default_opts = {})