مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2025-12-01 05:43:04 +00:00
fix(smtp-sender): fixes SMTPSender.smtp_relays
هذا الالتزام موجود في:
@@ -244,11 +244,11 @@ class SMTPSender < BaseSender
|
|||||||
relays = Postal::Config.postal.smtp_relays
|
relays = Postal::Config.postal.smtp_relays
|
||||||
return nil if relays.nil?
|
return nil if relays.nil?
|
||||||
|
|
||||||
relays.map do |relay|
|
relays = relays.map do |relay|
|
||||||
next unless relay.host.present?
|
next unless relay.host.present?
|
||||||
|
|
||||||
SMTPClient::Server.new(relay.host, relay.port, ssl_mode: relay.ssl_mode)
|
SMTPClient::Server.new(relay.host, port: relay.port, ssl_mode: relay.ssl_mode)
|
||||||
end.compact
|
end
|
||||||
|
|
||||||
@smtp_relays = relays.empty? ? nil : relays
|
@smtp_relays = relays.empty? ? nil : relays
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -524,4 +524,41 @@ RSpec.describe SMTPSender do
|
|||||||
expect(sender.endpoints).to all have_received(:finish_smtp_session).at_least(:once)
|
expect(sender.endpoints).to all have_received(:finish_smtp_session).at_least(:once)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe ".smtp_relays" do
|
||||||
|
before do
|
||||||
|
if described_class.instance_variable_defined?("@smtp_relays")
|
||||||
|
described_class.remove_instance_variable("@smtp_relays")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns nil if smtp relays is nil" do
|
||||||
|
allow(Postal::Config.postal).to receive(:smtp_relays).and_return(nil)
|
||||||
|
expect(described_class.smtp_relays).to be nil
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns nil if there are no smtp relays" do
|
||||||
|
allow(Postal::Config.postal).to receive(:smtp_relays).and_return([])
|
||||||
|
expect(described_class.smtp_relays).to be nil
|
||||||
|
end
|
||||||
|
|
||||||
|
it "does not return relays where the host is nil" do
|
||||||
|
allow(Postal::Config.postal).to receive(:smtp_relays).and_return([
|
||||||
|
Hashie::Mash.new(host: nil, port: 25, ssl_mode: "Auto"),
|
||||||
|
Hashie::Mash.new(host: "test.example.com", port: 25, ssl_mode: "Auto"),
|
||||||
|
])
|
||||||
|
expect(described_class.smtp_relays).to match [kind_of(SMTPClient::Server)]
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns relays with options" do
|
||||||
|
allow(Postal::Config.postal).to receive(:smtp_relays).and_return([
|
||||||
|
Hashie::Mash.new(host: "test.example.com", port: 25, ssl_mode: "Auto"),
|
||||||
|
Hashie::Mash.new(host: "test2.example.com", port: 2525, ssl_mode: "TLS"),
|
||||||
|
])
|
||||||
|
expect(described_class.smtp_relays).to match [
|
||||||
|
have_attributes(hostname: "test.example.com", port: 25, ssl_mode: "Auto"),
|
||||||
|
have_attributes(hostname: "test2.example.com", port: 2525, ssl_mode: "TLS"),
|
||||||
|
]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم