config: refactor email settings.
* Add `Danbooru.config.mail_delivery_method` option. * Remove `Danbooru.config.aws_ses_enabled?` option. * Replace `Danbooru.config.aws_ses_options` with `Danbooru.config.mail_settings`.
This commit is contained in:
@@ -32,9 +32,15 @@ module Danbooru
|
|||||||
config.autoload_paths += %W(#{config.root}/app/presenters #{config.root}/app/logical #{config.root}/app/mailers)
|
config.autoload_paths += %W(#{config.root}/app/presenters #{config.root}/app/logical #{config.root}/app/mailers)
|
||||||
config.plugins = [:all]
|
config.plugins = [:all]
|
||||||
config.time_zone = 'Eastern Time (US & Canada)'
|
config.time_zone = 'Eastern Time (US & Canada)'
|
||||||
config.action_mailer.delivery_method = :smtp
|
|
||||||
config.action_mailer.smtp_settings = {:enable_starttls_auto => false}
|
if Danbooru.config.mail_delivery_method.to_sym == :smtp
|
||||||
config.action_mailer.perform_deliveries = true
|
config.action_mailer.delivery_method = :smtp
|
||||||
|
config.action_mailer.smtp_settings = Danbooru.config.mail_settings
|
||||||
|
elsif Danbooru.config.mail_delivery_method.to_sym == :sendmail
|
||||||
|
config.action_mailer.delivery_method = :sendmail
|
||||||
|
config.action_mailer.sendmail_settings = Danbooru.config.mail_settings
|
||||||
|
end
|
||||||
|
|
||||||
config.log_tags = [->(req) {"PID:#{Process.pid}"}]
|
config.log_tags = [->(req) {"PID:#{Process.pid}"}]
|
||||||
config.action_controller.action_on_unpermitted_parameters = :raise
|
config.action_controller.action_on_unpermitted_parameters = :raise
|
||||||
config.force_ssl = true
|
config.force_ssl = true
|
||||||
|
|||||||
@@ -159,6 +159,22 @@ module Danbooru
|
|||||||
1.week.ago
|
1.week.ago
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# https://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration
|
||||||
|
# https://guides.rubyonrails.org/configuring.html#configuring-action-mailer
|
||||||
|
def mail_delivery_method
|
||||||
|
# :smtp
|
||||||
|
:sendmail
|
||||||
|
end
|
||||||
|
|
||||||
|
def mail_settings
|
||||||
|
{
|
||||||
|
# address: "example.com",
|
||||||
|
# user_name: "user",
|
||||||
|
# password: "pass",
|
||||||
|
# authentication: :login
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
# Permanently redirect all HTTP requests to HTTPS.
|
# Permanently redirect all HTTP requests to HTTPS.
|
||||||
#
|
#
|
||||||
# https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security
|
# https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security
|
||||||
@@ -561,14 +577,6 @@ module Danbooru
|
|||||||
def aws_secret_access_key
|
def aws_secret_access_key
|
||||||
end
|
end
|
||||||
|
|
||||||
def aws_ses_enabled?
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
def aws_ses_options
|
|
||||||
# {:smtp_server_name => "smtp server", :user_name => "user name", :ses_smtp_user_name => "smtp user name", :ses_smtp_password => "smtp password"}
|
|
||||||
end
|
|
||||||
|
|
||||||
def aws_sqs_region
|
def aws_sqs_region
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
if Danbooru.config.aws_ses_enabled? && Rails.env == "production"
|
|
||||||
Rails.application.config.action_mailer.smtp_settings = {
|
|
||||||
:address => Danbooru.config.aws_ses_options[:smtp_server_name],
|
|
||||||
:user_name => Danbooru.config.aws_ses_options[:ses_smtp_user_name],
|
|
||||||
:password => Danbooru.config.aws_ses_options[:ses_smtp_password],
|
|
||||||
:authentication => :login,
|
|
||||||
:enable_starttls_auto => true
|
|
||||||
}
|
|
||||||
end
|
|
||||||
Reference in New Issue
Block a user