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

Properly cast booleans from ENV input

Oliver Günther96f246e3cb6e
diff --git a/lib/tasks/email.rake b/lib/tasks/email.rake
index 8d21f519d20..9c8e26799d4 100644
--- a/lib/tasks/email.rake
+++ b/lib/tasks/email.rake
@@ -137,15 +137,17 @@ namespace :redmine do
END_DESC
task receive_imap: :environment do
- imap_options = { host: ENV.fetch('host', nil),
- port: ENV.fetch('port', nil),
- ssl: ENV.fetch('ssl', nil),
- ssl_verification: !['0', 'false', 'f'].include?(ENV.fetch('ssl_verification', nil)),
- username: ENV.fetch('username', nil),
- password: ENV.fetch('password', nil),
- folder: ENV.fetch('folder', nil),
- move_on_success: ENV.fetch('move_on_success', nil),
- move_on_failure: ENV.fetch('move_on_failure', nil) }
+ imap_options = {
+ host: ENV.fetch('host', nil),
+ port: ENV.fetch('port', nil),
+ ssl: ActiveRecord::Type::Boolean.new.cast(ENV.fetch('ssl', true)),
+ ssl_verification: ActiveRecord::Type::Boolean.new.cast(ENV.fetch('ssl_verification', true)),
+ username: ENV.fetch('username', nil),
+ password: ENV.fetch('password', nil),
+ folder: ENV.fetch('folder', nil),
+ move_on_success: ActiveRecord::Type::Boolean.new.cast(ENV.fetch('move_on_success', nil)),
+ move_on_failure: ActiveRecord::Type::Boolean.new.cast(ENV.fetch('move_on_failure', nil))
+ }
Redmine::IMAP.check(imap_options, options_from_env)
end