mirror of
https://github.com/mastodon/mastodon.git
synced 2025-11-29 10:53:39 +00:00
Fix SMTP configuration with mail 2.9.0 (#36646)
This commit is contained in:
parent
2a9c7d2b9e
commit
e4291e9b05
|
|
@ -8,25 +8,23 @@ module Mastodon
|
|||
# `config/email.yml`) into the format that `ActionMailer` understands
|
||||
def convert_smtp_settings(config)
|
||||
enable_starttls = nil
|
||||
enable_starttls_auto = nil
|
||||
|
||||
case config[:enable_starttls]
|
||||
when 'always'
|
||||
enable_starttls = true
|
||||
when 'never'
|
||||
enable_starttls = :always
|
||||
when 'never', 'false'
|
||||
enable_starttls = false
|
||||
when 'auto'
|
||||
enable_starttls_auto = true
|
||||
enable_starttls = :auto
|
||||
else
|
||||
enable_starttls_auto = config[:enable_starttls_auto] != 'false'
|
||||
enable_starttls = config[:enable_starttls_auto] ? :auto : false unless config[:tls] || config[:ssl]
|
||||
end
|
||||
|
||||
authentication = config[:authentication] == 'none' ? nil : (config[:authentication] || 'plain')
|
||||
|
||||
config.merge(
|
||||
config.without(:enable_starttls_auto).merge(
|
||||
authentication:,
|
||||
enable_starttls:,
|
||||
enable_starttls_auto:
|
||||
enable_starttls:
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -21,8 +21,9 @@ RSpec.describe Mastodon::EmailConfigurationHelper do
|
|||
base_configuration.merge({ enable_starttls: 'always' })
|
||||
end
|
||||
|
||||
it 'converts this to `true`' do
|
||||
expect(converted_settings[:enable_starttls]).to be true
|
||||
it 'converts this to `:always`' do
|
||||
expect(converted_settings[:enable_starttls]).to eq :always
|
||||
expect(converted_settings[:enable_starttls_auto]).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -33,6 +34,7 @@ RSpec.describe Mastodon::EmailConfigurationHelper do
|
|||
|
||||
it 'converts this to `false`' do
|
||||
expect(converted_settings[:enable_starttls]).to be false
|
||||
expect(converted_settings[:enable_starttls_auto]).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -41,28 +43,43 @@ RSpec.describe Mastodon::EmailConfigurationHelper do
|
|||
base_configuration.merge({ enable_starttls: 'auto' })
|
||||
end
|
||||
|
||||
it 'sets `enable_starttls_auto` instead' do
|
||||
expect(converted_settings[:enable_starttls]).to be_nil
|
||||
expect(converted_settings[:enable_starttls_auto]).to be true
|
||||
it 'sets `enable_starttls` to `:auto`' do
|
||||
expect(converted_settings[:enable_starttls]).to eq :auto
|
||||
expect(converted_settings[:enable_starttls_auto]).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when `enable_starttls` is unset' do
|
||||
context 'when `enable_starttls_auto` is unset' do
|
||||
let(:configuration) { base_configuration }
|
||||
|
||||
it 'sets `enable_starttls_auto` to `true`' do
|
||||
expect(converted_settings[:enable_starttls_auto]).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'when `enable_starttls_auto` is set to "false"' do
|
||||
context 'when `enable_starttls_auto` is true' do
|
||||
let(:configuration) do
|
||||
base_configuration.merge({ enable_starttls_auto: 'false' })
|
||||
base_configuration.merge({ enable_starttls_auto: true })
|
||||
end
|
||||
|
||||
it 'sets `enable_starttls_auto` to `false`' do
|
||||
expect(converted_settings[:enable_starttls_auto]).to be false
|
||||
it 'sets `enable_starttls` to `:auto`' do
|
||||
expect(converted_settings[:enable_starttls]).to eq :auto
|
||||
expect(converted_settings[:enable_starttls_auto]).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when `tls` is set to true' do
|
||||
let(:configuration) do
|
||||
base_configuration.merge({ tls: true })
|
||||
end
|
||||
|
||||
it 'sets `enable_starttls` to `nil`' do
|
||||
expect(converted_settings[:enable_starttls]).to be_nil
|
||||
expect(converted_settings[:enable_starttls_auto]).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when `enable_starttls_auto` is set to false' do
|
||||
let(:configuration) do
|
||||
base_configuration.merge({ enable_starttls_auto: false })
|
||||
end
|
||||
|
||||
it 'sets `enable_starttls` to `false`' do
|
||||
expect(converted_settings[:enable_starttls]).to be false
|
||||
expect(converted_settings[:enable_starttls_auto]).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ RSpec.describe UserMailer do
|
|||
address: 'localhost',
|
||||
port: 25,
|
||||
authentication: 'none',
|
||||
enable_starttls_auto: true,
|
||||
}
|
||||
end
|
||||
|
||||
|
|
@ -44,8 +45,7 @@ RSpec.describe UserMailer do
|
|||
address: 'localhost',
|
||||
port: 25,
|
||||
authentication: nil,
|
||||
enable_starttls: nil,
|
||||
enable_starttls_auto: true,
|
||||
enable_starttls: :auto,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user