OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
turn OpenProject::Notifications static
ulferts3492d08fdd46
diff --git a/config/initializers/00-load_lib_static.rb b/config/initializers/00-load_lib_static.rbindex 9064ab301d1..ebf63d54583 100644--- a/config/initializers/00-load_lib_static.rb+++ b/config/initializers/00-load_lib_static.rb@@ -34,6 +34,7 @@ require Rails.root.join('lib_static/redmine/diff/diffable')require Rails.root.join('lib_static/redmine/diff/array_string_diff')require Rails.root.join('lib_static/plugins/load_path_helper')+require Rails.root.join('lib_static/open_project/notifications')# Loads the core plugins located in lib_static/pluginsDir.glob(Rails.root.join('lib_static/plugins/*')).each do |directory|diff --git a/config/initializers/subscribe_listeners.rb b/config/initializers/subscribe_listeners.rbindex 2d75328f0fc..8b6f39138f6 100644--- a/config/initializers/subscribe_listeners.rb+++ b/config/initializers/subscribe_listeners.rb@@ -26,59 +26,61 @@# See COPYRIGHT and LICENSE files for more details.#++-OpenProject::Notifications.subscribe(OpenProject::Events::JOURNAL_CREATED) do |payload|- # A job is scheduled that creates notifications (in app if supported) right away and schedules- # jobs to be run for mail and digest mails.- Notifications::WorkflowJob- .perform_later(:create_notifications,- payload[:journal],- payload[:send_notification])+Rails.application.config.after_initialize do+ OpenProject::Notifications.subscribe(OpenProject::Events::JOURNAL_CREATED) do |payload|+ # A job is scheduled that creates notifications (in app if supported) right away and schedules+ # jobs to be run for mail and digest mails.+ Notifications::WorkflowJob+ .perform_later(:create_notifications,+ payload[:journal],+ payload[:send_notification])- # A job is scheduled for the end of the journal aggregation time. If the journal does still exist- # at the end (it might be replaced because another journal was created within that timeframe)- # that job generates a OpenProject::Events::AGGREGATED_..._JOURNAL_READY event.- Journals::CompletedJob.schedule(payload[:journal], payload[:send_notification])-end+ # A job is scheduled for the end of the journal aggregation time. If the journal does still exist+ # at the end (it might be replaced because another journal was created within that timeframe)+ # that job generates a OpenProject::Events::AGGREGATED_..._JOURNAL_READY event.+ Journals::CompletedJob.schedule(payload[:journal], payload[:send_notification])+ end-OpenProject::Notifications.subscribe(OpenProject::Events::JOURNAL_AGGREGATE_BEFORE_DESTROY) do |payload|- Notifications::AggregatedJournalService.relocate_immediate(**payload.slice(:journal, :predecessor))-end+ OpenProject::Notifications.subscribe(OpenProject::Events::JOURNAL_AGGREGATE_BEFORE_DESTROY) do |payload|+ Notifications::AggregatedJournalService.relocate_immediate(**payload.slice(:journal, :predecessor))+ end-OpenProject::Notifications.subscribe(OpenProject::Events::WATCHER_ADDED) do |payload|- next unless payload[:send_notifications]+ OpenProject::Notifications.subscribe(OpenProject::Events::WATCHER_ADDED) do |payload|+ next unless payload[:send_notifications]- Mails::WatcherAddedJob- .perform_later(payload[:watcher],- payload[:watcher_setter])-end+ Mails::WatcherAddedJob+ .perform_later(payload[:watcher],+ payload[:watcher_setter])+ end-OpenProject::Notifications.subscribe(OpenProject::Events::WATCHER_REMOVED) do |payload|- Mails::WatcherRemovedJob- .perform_later(payload[:watcher].attributes,- payload[:watcher_remover])-end+ OpenProject::Notifications.subscribe(OpenProject::Events::WATCHER_REMOVED) do |payload|+ Mails::WatcherRemovedJob+ .perform_later(payload[:watcher].attributes,+ payload[:watcher_remover])+ end-OpenProject::Notifications.subscribe(OpenProject::Events::MEMBER_CREATED) do |payload|- next unless payload[:send_notifications]+ OpenProject::Notifications.subscribe(OpenProject::Events::MEMBER_CREATED) do |payload|+ next unless payload[:send_notifications]- Mails::MemberCreatedJob- .perform_later(current_user: User.current,- member: payload[:member],- message: payload[:message])-end+ Mails::MemberCreatedJob+ .perform_later(current_user: User.current,+ member: payload[:member],+ message: payload[:message])+ end-OpenProject::Notifications.subscribe(OpenProject::Events::MEMBER_UPDATED) do |payload|- next unless payload[:send_notifications]+ OpenProject::Notifications.subscribe(OpenProject::Events::MEMBER_UPDATED) do |payload|+ next unless payload[:send_notifications]- Mails::MemberUpdatedJob- .perform_later(current_user: User.current,- member: payload[:member],- message: payload[:message])-end+ Mails::MemberUpdatedJob+ .perform_later(current_user: User.current,+ member: payload[:member],+ message: payload[:message])+ end-OpenProject::Notifications.subscribe(OpenProject::Events::NEWS_COMMENT_CREATED) do |payload|- Notifications::WorkflowJob- .perform_later(:create_notifications,- payload[:comment],- payload[:send_notification])+ OpenProject::Notifications.subscribe(OpenProject::Events::NEWS_COMMENT_CREATED) do |payload|+ Notifications::WorkflowJob+ .perform_later(:create_notifications,+ payload[:comment],+ payload[:send_notification])+ endenddiff --git a/lib/open_project/notifications.rb b/lib_static/open_project/notifications.rbsimilarity index 100%rename from lib/open_project/notifications.rbrename to lib_static/open_project/notifications.rbdiff --git a/modules/github_integration/lib/open_project/github_integration/engine.rb b/modules/github_integration/lib/open_project/github_integration/engine.rbindex 3bfc7466f3d..a0a3eb8e678 100644--- a/modules/github_integration/lib/open_project/github_integration/engine.rb+++ b/modules/github_integration/lib/open_project/github_integration/engine.rb@@ -53,13 +53,15 @@ module OpenProject::GithubIntegrationendend- initializer 'github.subscribe_to_notifications' do- ::OpenProject::Notifications.subscribe('github.check_run',- &NotificationHandler.method(:check_run))- ::OpenProject::Notifications.subscribe('github.issue_comment',- &NotificationHandler.method(:issue_comment))- ::OpenProject::Notifications.subscribe('github.pull_request',- &NotificationHandler.method(:pull_request))+ initializer 'github.subscribe_to_notifications' do |app|+ app.config.after_initialize do+ ::OpenProject::Notifications.subscribe('github.check_run',+ &NotificationHandler.method(:check_run))+ ::OpenProject::Notifications.subscribe('github.issue_comment',+ &NotificationHandler.method(:issue_comment))+ ::OpenProject::Notifications.subscribe('github.pull_request',+ &NotificationHandler.method(:pull_request))+ endendextend_api_response(:v3, :work_packages, :work_package,diff --git a/modules/webhooks/lib/open_project/webhooks/engine.rb b/modules/webhooks/lib/open_project/webhooks/engine.rbindex 5cce8e5b459..5bb43ea2aa3 100644--- a/modules/webhooks/lib/open_project/webhooks/engine.rb+++ b/modules/webhooks/lib/open_project/webhooks/engine.rb@@ -45,8 +45,10 @@ module OpenProject::Webhookscaption: :'webhooks.plural'end- initializer 'webhooks.subscribe_to_notifications' do- ::OpenProject::Webhooks::EventResources.subscribe!+ initializer 'webhooks.subscribe_to_notifications' do |app|+ app.config.after_initialize do+ ::OpenProject::Webhooks::EventResources.subscribe!+ endendendend