mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 09:12:45 +08:00
FIX: Prevent Email Processor errors when mail is blank or nil (#21292)
Currently processing emails that are blank or have a nil value for the mail will cause several errors. This update allows emails with blank body or missing sender to log the blank email error to the mail logs rather than throwing an error.
This commit is contained in:
parent
4ec9a947dc
commit
1de8361d2e
|
@ -24,7 +24,7 @@ module Email
|
|||
raise
|
||||
end
|
||||
rescue => e
|
||||
return handle_bounce(e) if @receiver.is_bounce?
|
||||
return handle_bounce(e) if @receiver&.is_bounce?
|
||||
|
||||
log_email_process_failure(@mail, e)
|
||||
incoming_email = @receiver.try(:incoming_email)
|
||||
|
@ -156,7 +156,7 @@ module Email
|
|||
end
|
||||
|
||||
def can_send_rejection_email?(email, type)
|
||||
return false if @receiver.sent_to_mailinglist_mirror?
|
||||
return false if @receiver&.sent_to_mailinglist_mirror?
|
||||
return true if type == :email_reject_unrecognized_error
|
||||
|
||||
key = "rejection_email:#{email}:#{type}:#{Date.today}"
|
||||
|
|
|
@ -48,6 +48,13 @@ RSpec.describe Email::Processor do
|
|||
end
|
||||
end
|
||||
|
||||
describe "when mail is not set" do
|
||||
it "does not raise an error" do
|
||||
expect { Email::Processor.process!(nil) }.not_to raise_error
|
||||
expect { Email::Processor.process!("") }.not_to raise_error
|
||||
end
|
||||
end
|
||||
|
||||
describe "rate limits" do
|
||||
let(:mail) { "From: #{from}\nTo: bar@foo.com\nSubject: FOO BAR\n\nFoo foo bar bar?" }
|
||||
let(:limit_exceeded) { RateLimiter::LimitExceeded.new(10) }
|
||||
|
|
Loading…
Reference in New Issue
Block a user