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

This commit is contained in:
Mark VanLandingham 2024-02-29 08:33:38 -06:00 committed by GitHub
parent 03de0421af
commit 0a58b18970
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 2 deletions

View File

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