Skip to content

A platform for community discussion. Free, open, simple.

DEV: Move DiscourseEvent trigger in PostAlerter#push_notification (#25931)

Mark VanLandingham0a58b1897098
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 = {})