Skip to content

Commit

Permalink
fix(message-dequeuer): ensure SMTP endpoints are sent to SMTP sender …
Browse files Browse the repository at this point in the history
…appropriately

closes #2853
  • Loading branch information
adamcooke committed Mar 6, 2024
1 parent 4e1deb2 commit e2d642c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/lib/message_dequeuer/incoming_message_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def send_message_to_sender

case queued_message.message.endpoint
when SMTPEndpoint
sender = @state.sender_for(SMTPSender, queued_message.message.recipient_domain, nil, servers: [queued_message.message.endpoint])
sender = @state.sender_for(SMTPSender, queued_message.message.recipient_domain, nil, servers: [queued_message.message.endpoint.to_smtp_client_server])
when HTTPEndpoint
sender = @state.sender_for(HTTPSender, queued_message.message.endpoint)
when AddressEndpoint
Expand Down
4 changes: 4 additions & 0 deletions app/models/smtp_endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,8 @@ def update_routes
routes.each { |r| r.update(endpoint: nil, mode: "Reject") }
end

def to_smtp_client_server
SMTPClient::Server.new(hostname, port: port || 25, ssl_mode: ssl_mode)
end

end
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ module MessageDequeuer
it "gets a sender from the state and sends the message to it" do
smtp_sender_double = double("SMTPSender")
expect(smtp_sender_double).to receive(:send_message).with(queued_message.message).and_return(SendResult.new)
expect(state).to receive(:sender_for).with(SMTPSender, message.recipient_domain, nil, { servers: [endpoint] }).and_return(smtp_sender_double)
expect(state).to receive(:sender_for).with(SMTPSender, message.recipient_domain, nil, { servers: [kind_of(SMTPClient::Server)] }).and_return(smtp_sender_double)
processor.process
end
end
Expand Down

0 comments on commit e2d642c

Please sign in to comment.