Follow up - 6309eacc55 - Fixes #3110 - ServiceNow mails from other service providers are not detected: Enhanced handling of key insensitive ServiceNow sender address.

This commit is contained in:
Thorsten Eckel 2020-07-09 17:06:20 +02:00
parent 6309eacc55
commit 5d9ecee99c
2 changed files with 13 additions and 11 deletions

View file

@ -66,17 +66,10 @@ returns:
=end
def self.source_name(from:)
result = nil
begin
Mail::AddressList.new(from).addresses.each do |line|
result = "ServiceNow-#{line.address}"
break
end
rescue
Rails.logger.info "Unable to parse email address in '#{from}'"
end
result
address = Mail::AddressList.new(from).addresses.first.address.downcase
"ServiceNow-#{address}"
rescue => e
Rails.logger.info "Unable to parse email address in '#{from}': #{e.message}"
end
def self.from_sync_entry(mail:, source_name:, source_id:)

View file

@ -1024,6 +1024,15 @@ RSpec.describe Channel::EmailParser, type: :model do
it 'adds Article to existing Ticket' do
expect { described_class.new.process({}, raw_mail) }.to change { ticket.reload.articles.count }
end
context 'key insensitive sender address' do
let(:raw_mail) { super().gsub('example@service-now.com', 'Example@Service-Now.com') }
it 'adds Article to existing Ticket' do
expect { described_class.new.process({}, raw_mail) }.to change { ticket.reload.articles.count }
end
end
end
end