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

Fixed suggestions from PR for health mailing

Andreas Pfohld5aa9c406886
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 0bcb2c86e68..57626a9c851 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -108,7 +108,6 @@ Rails.application.configure do
config.action_controller.raise_on_missing_callback_actions = true
# Send mails to browser window
- config.action_mailer.delivery_method = :letter_opener
config.action_mailer.delivery_method = File.exist?('/.dockerenv') ? :letter_opener_web : :letter_opener
# Set email preview locations to rspec
diff --git a/modules/storages/app/workers/storages/health_status_mailer_job.rb b/modules/storages/app/workers/storages/health_status_mailer_job.rb
index e6decbc750f..ae715f5b2ed 100644
--- a/modules/storages/app/workers/storages/health_status_mailer_job.rb
+++ b/modules/storages/app/workers/storages/health_status_mailer_job.rb
@@ -30,24 +30,33 @@
module Storages
class HealthStatusMailerJob < ApplicationJob
- def perform(admins:, storage:)
- if storage.health_healthy?
- return
- end
+ def perform(storage:)
+ return unless Storages::Storage.exists?(storage.id)
+
+ storage.reload
+
+ return if storage.health_healthy?
- admins.each do |admin|
- Storages::StoragesMailer.notify_unhealthy(admin, storage).deliver_now
+ admin_users.each do |admin|
+ Storages::StoragesMailer.notify_unhealthy(admin, storage).deliver_later
end
- HealthStatusMailerJob.schedule(admins:, storage:)
+ HealthStatusMailerJob.schedule(storage:)
end
class << self
- def schedule(admins:, storage:)
+ def schedule(storage:)
next_run_time = Date.tomorrow.beginning_of_day + 2.hours
- HealthStatusMailerJob.set(wait_until: next_run_time).perform_later(admins: admins.records, storage:)
+ HealthStatusMailerJob.set(wait_until: next_run_time).perform_later(storage:)
end
end
+
+ private
+
+ def admin_users
+ User.where(admin: true)
+ .where.not(mail: [nil, ''])
+ end
end
end