Skip to content

Commit

Permalink
Longer timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
parterburn committed Jan 29, 2024
1 parent 756b29d commit 46c55b8
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions app/lib/email_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -364,18 +364,15 @@ def collage_from_mailgun_attachments
return unless @message_id.present?

last_message = nil
5.times do
connection = Faraday.new("https://api.mailgun.net") do |f|
f.options[:timeout] = 29
f.request :json
f.response :json
f.request :authorization, :basic, 'api', ENV['MAILGUN_API_KEY']
end
resp = connection.get("/v3/#{ENV['SMTP_DOMAIN']}/events?pretty=yes&event=accepted&ascending=no&limit=1&message-id=#{@message_id}")
last_message = resp.body&.dig("items", 0) if resp.success?
break if last_message.present?
sleep 10
connection = Faraday.new(url: "https://api.mailgun.net") do |f|
f.request :json
f.response :json
f.request :authorization, :basic, 'api', ENV['MAILGUN_API_KEY']
f.options.timeout = 20
f.options.open_timeout = 20
end
resp = connection.get("/v3/#{ENV['SMTP_DOMAIN']}/events?pretty=yes&event=accepted&ascending=no&limit=1&message-id=#{@message_id}")
last_message = resp.body&.dig("items", 0) if resp.success?
return unless last_message.present?

message = nil
Expand Down

0 comments on commit 46c55b8

Please sign in to comment.