Skip to content

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

Merge remote-tracking branch 'origin/dev' into implementation/50915-send-an-email-with-the-information-and-how-to-fix-it

Andreas Pfohl6ad1e62c3cb0
diff --cc Gemfile
index e532c9c4acb,f7059356a44..3fcc7aef2a7
--- a/Gemfile
+++ b/Gemfile
@@@ -291,19 -290,18 +290,18 @@@ group :ldap d
end
group :development do
- gem 'listen', '~> 3.9.0' # Use for event-based reloaders
+ gem "listen", "~> 3.9.0" # Use for event-based reloaders
- gem 'letter_opener'
- gem "letter_opener"
+ gem 'letter_opener_web'
- gem 'spring'
- gem 'spring-commands-rspec'
- gem 'spring-commands-rubocop'
+ gem "spring"
+ gem "spring-commands-rspec"
+ gem "spring-commands-rubocop"
- gem 'colored2'
+ gem "colored2"
# git hooks manager
- gem 'lefthook', require: false
+ gem "lefthook", require: false
end
group :development, :test do
diff --cc Gemfile.lock
index 285f800afca,7934200f805..af7b565e124
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@@ -662,13 -678,9 +677,13 @@@ GE
launchy (3.0.0)
addressable (~> 2.8)
childprocess (~> 5.0)
- lefthook (1.6.5)
+ lefthook (1.6.7)
letter_opener (1.0.0)
launchy (>= 2.0.4)
+ letter_opener_web (1.4.1)
+ actionmailer (>= 3.2)
+ letter_opener (~> 1.0)
+ railties (>= 3.2)
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
@@@ -710,10 -722,11 +725,10 @@@
method_source (1.0.0)
mime-types (3.5.2)
mime-types-data (~> 3.2015)
- mime-types-data (3.2024.0206)
+ mime-types-data (3.2024.0305)
mini_magick (4.12.0)
mini_mime (1.1.5)
- minitest (5.22.2)
- mini_portile2 (2.8.5)
+ minitest (5.22.3)
msgpack (1.7.2)
multi_json (1.15.0)
mustermann (3.0.0)
@@@ -734,7 -747,8 +749,7 @@@
net-smtp (0.4.0.1)
net-protocol
nio4r (2.7.0)
- nokogiri (1.16.2-x86_64-linux)
- nokogiri (1.16.3)
- mini_portile2 (~> 2.8.2)
++ nokogiri (1.16.3-x86_64-linux)
racc (~> 1.4)
oj (3.16.3)
bigdecimal (>= 3.0)
@@@ -1196,8 -1230,7 +1230,7 @@@ DEPENDENCIE
ladle
launchy (~> 3.0.0)
lefthook
-- letter_opener
+ letter_opener_web
listen (~> 3.9.0)
lograge (~> 0.14.0)
lookbook (~> 2.2.1)
diff --cc config/routes.rb
index ce5c932ad67,89c4963a26d..a49cb0b0202
--- a/config/routes.rb
+++ b/config/routes.rb
@@@ -652,6 -652,6 +652,7 @@@ Rails.application.routes.draw d
end
if Rails.env.development?
+ mount LetterOpenerWeb::Engine, at: "/letter_opener"
+ mount GoodJob::Engine => "good_job"
end
end
diff --cc modules/storages/app/workers/storages/manage_nextcloud_integration_job.rb
index 00000000000,fe38ffaea2c..e9616253014
mode 000000,100644..100644
--- a/modules/storages/app/workers/storages/manage_nextcloud_integration_job.rb
+++ b/modules/storages/app/workers/storages/manage_nextcloud_integration_job.rb
@@@ -1,0 -1,109 +1,110 @@@
+ #-- copyright
+ # OpenProject is an open source project management software.
+ # Copyright (C) 2012-2024 the OpenProject GmbH
+ #
+ # This program is free software; you can redistribute it and/or
+ # modify it under the terms of the GNU General Public License version 3.
+ #
+ # OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+ # Copyright (C) 2006-2013 Jean-Philippe Lang
+ # Copyright (C) 2010-2013 the ChiliProject Team
+ #
+ # This program is free software; you can redistribute it and/or
+ # modify it under the terms of the GNU General Public License
+ # as published by the Free Software Foundation; either version 2
+ # of the License, or (at your option) any later version.
+ #
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ # GNU General Public License for more details.
+ #
+ # You should have received a copy of the GNU General Public License
+ # along with this program; if not, write to the Free Software
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ #
+ # See COPYRIGHT and LICENSE files for more details.
+ #++
+
+ module Storages
+ class ManageNextcloudIntegrationJob < ApplicationJob
+ include GoodJob::ActiveJobExtensions::Concurrency
+ using ::Storages::Peripherals::ServiceResultRefinements
+
+ good_job_control_concurrency_with(
+ total_limit: 2,
+ enqueue_limit: 1,
+ perform_limit: 1,
+ key: "ManageNextcloudIntegrationJob"
+ )
+ SINGLE_THREAD_DEBOUNCE_TIME = 4.seconds.freeze
+ KEY = :manage_nextcloud_integration_job_debounce_happend_at
+ CRON_JOB_KEY = :'Storages::ManageNextcloudIntegrationJob'
+
+ queue_with_priority :above_normal
+
+ class << self
+ def debounce
+ if debounce_happend_in_current_thread_recently?
+ false
+ else
+ # TODO:
+ # Why there is 5 seconds delay?
+ # it is like that because for 1 thread and if there is no delay more than
+ # SINGLE_THREAD_DEBOUNCE_TIME(4.seconds)
+ # then some events can be lost
+ #
+ # Possibly "true" solutions are:
+ # 1. have after_request middleware to schedule one job after a request cycle
+ # 2. use concurrent ruby to have 'true' debounce.
+ result = set(wait: 5.seconds).perform_later
+ RequestStore.store[KEY] = Time.current
+ result
+ end
+ end
+
+ def disable_cron_job_if_needed
+ if ::Storages::ProjectStorage.active_automatically_managed.exists?
+ GoodJob::Setting.cron_key_enable(CRON_JOB_KEY) unless GoodJob::Setting.cron_key_enabled?(CRON_JOB_KEY)
+ elsif GoodJob::Setting.cron_key_enabled?(CRON_JOB_KEY)
+ GoodJob::Setting.cron_key_disable(CRON_JOB_KEY)
+ end
+ end
+
+ private
+
+ def debounce_happend_in_current_thread_recently?
+ timestamp = RequestStore.store[KEY]
+ timestamp.present? && (timestamp + SINGLE_THREAD_DEBOUNCE_TIME) > Time.current
+ end
+ end
+
+ def perform
+ find_storages do |storage|
+ next unless storage.configured?
++
+ result = service_for(storage).call(storage)
+ result.match(
+ on_success: ->(_) { storage.mark_as_healthy },
+ on_failure: ->(errors) { storage.mark_as_unhealthy(reason: errors.to_s) }
+ )
+ end
+ end
+
+ private
+
+ def find_storages(&)
+ ::Storages::Storage
+ .automatic_management_enabled
+ .includes(:oauth_client)
+ .find_each(&)
+ end
+
+ def service_for(storage)
+ return NextcloudGroupFolderPropertiesSyncService if storage.provider_type_nextcloud?
+ return OneDriveManagedFolderSyncService if storage.provider_type_one_drive?
+
+ raise 'Unknown Storage'
+ end
+ end
+ end
diff --cc modules/storages/lib/open_project/storages/engine.rb
index a479f41dd2a,db4a75c1cea..66a57a4e999
--- a/modules/storages/lib/open_project/storages/engine.rb
+++ b/modules/storages/lib/open_project/storages/engine.rb
@@@ -69,19 -69,17 +69,19 @@@ module OpenProject::Storage
OpenProject::Notifications.subscribe(
OpenProject::Events::OAUTH_CLIENT_TOKEN_CREATED
) do |payload|
- if payload[:integration_type] == 'Storages::Storage'
- ::Storages::ManageNextcloudIntegrationEventsJob.debounce
+ if payload[:integration_type] == "Storages::Storage"
+ ::Storages::ManageNextcloudIntegrationJob.debounce
end
end
+
OpenProject::Notifications.subscribe(
OpenProject::Events::ROLE_UPDATED
) do |payload|
if payload[:permissions_diff]&.intersect?(OpenProject::Storages::Engine.permissions)
- ::Storages::ManageNextcloudIntegrationEventsJob.debounce
+ ::Storages::ManageNextcloudIntegrationJob.debounce
end
end
+
OpenProject::Notifications.subscribe(
OpenProject::Events::ROLE_DESTROYED
) do |payload|