Commit 6e290267 authored by Vitali Tatarintev's avatar Vitali Tatarintev

Merge branch '340167-exclude-body-when-sending-rejection-email' into 'master'

Strip out email body when rejecting email

See merge request gitlab-org/gitlab!73335
parents 3e7832fe 60b5f228
......@@ -118,7 +118,9 @@ class EmailReceiverWorker # rubocop:disable Scalability/IdempotentWorker
end
if reason
EmailRejectionMailer.rejection(reason, raw, can_retry).deliver_later
receiver.mail.body = nil
EmailRejectionMailer.rejection(reason, receiver.mail.encoded, can_retry).deliver_later
end
end
end
......@@ -44,6 +44,10 @@ module Gitlab
}
end
def mail
strong_memoize(:mail) { build_mail }
end
private
def handler
......@@ -54,10 +58,6 @@ module Gitlab
Handler.for(mail, mail_key)
end
def mail
strong_memoize(:mail) { build_mail }
end
def build_mail
Mail::Message.new(@raw)
rescue Encoding::UndefinedConversionError,
......
......@@ -37,6 +37,15 @@ RSpec.describe EmailReceiverWorker, :mailer do
expect(email.to).to eq(["jake@adventuretime.ooo"])
expect(email.subject).to include("Rejected")
end
it 'strips out the body before passing to EmailRejectionMailer' do
mail = Mail.new(raw_message)
mail.body = nil
expect(EmailRejectionMailer).to receive(:rejection).with(anything, mail.encoded, anything).and_call_original
described_class.new.perform(raw_message)
end
end
context 'when the error is Gitlab::Email::AutoGeneratedEmailError' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment