diff --git a/modules/storages/lib/open_project/storages/engine.rb b/modules/storages/lib/open_project/storages/engine.rb index b289194e622b..f6b4f6bca5a9 100644 --- a/modules/storages/lib/open_project/storages/engine.rb +++ b/modules/storages/lib/open_project/storages/engine.rb @@ -55,14 +55,25 @@ def self.permissions [ OpenProject::Events::MEMBER_CREATED, OpenProject::Events::MEMBER_UPDATED, - OpenProject::Events::MEMBER_DESTROYED, - OpenProject::Events::PROJECT_UPDATED, - OpenProject::Events::PROJECT_RENAMED, - OpenProject::Events::PROJECT_ARCHIVED, - OpenProject::Events::PROJECT_UNARCHIVED + OpenProject::Events::MEMBER_DESTROYED ].each do |event| OpenProject::Notifications.subscribe(event) do |_payload| - ::Storages::ManageStorageIntegrationsJob.debounce + Storages::Storage.joins(project_storages: :project) + .where(project_storages: { project_id: payload[:member].project_id }).find_each do |storage| + ::Storages::AutomaticallyManagedStorageSyncJob.debounce(storage) + end + end + end + + [OpenProject::Events::PROJECT_UPDATED, + OpenProject::Events::PROJECT_RENAMED, + OpenProject::Events::PROJECT_ARCHIVED, + OpenProject::Events::PROJECT_UNARCHIVED].each do |event| + OpenProject::Notifications.subscribe(event) do |payload| + Storages::Storage.joins(project_storages: :project) + .where(project_storages: { project_id: payload[:project] }).find_each do |storage| + ::Storages::AutomaticallyManagedStorageSyncJob.debounce(storage) + end end end