mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
FEATURE: A notification consolidation plan for keeping the latest one. (#15249)
We previously used ConsolidateNotifications with a threshold of 1 to re-use an existing notification and bump it to the top instead of creating a new one. It produces some jumpiness in the user notification list, and it relies on updating the `created_at` attribute, which is a bit hacky. As a better alternative, we're introducing a new plan that deletes all the previous versions of the notification, then creates a new one.
This commit is contained in:
@ -986,10 +986,11 @@ class Plugin::Instance
|
||||
#
|
||||
# The rule object is quite complex. We strongly recommend you write tests to ensure your plugin consolidates notifications correctly.
|
||||
#
|
||||
# - Plan's documentation: https://github.com/discourse/discourse/blob/main/app/services/notifications/consolidate_notifications.rb
|
||||
# - Threshold and time window consolidation plan: https://github.com/discourse/discourse/blob/main/app/services/notifications/consolidate_notifications.rb
|
||||
# - Create a new notification and delete previous versions plan: https://github.com/discourse/discourse/blob/main/app/services/notifications/delete_previous_notifications.rb
|
||||
# - Base plans: https://github.com/discourse/discourse/blob/main/app/services/notifications/consolidation_planner.rb
|
||||
def register_notification_consolidation_plan(plan)
|
||||
raise ArgumentError.new("Not a consolidation plan") if plan.class != Notifications::ConsolidateNotifications
|
||||
raise ArgumentError.new("Not a consolidation plan") if !plan.class.ancestors.include?(Notifications::ConsolidationPlan)
|
||||
DiscoursePluginRegistry.register_notification_consolidation_plan(plan, self)
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user