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 =end
def self.source_name(from:) def self.source_name(from:)
result = nil address = Mail::AddressList.new(from).addresses.first.address.downcase
begin "ServiceNow-#{address}"
Mail::AddressList.new(from).addresses.each do |line| rescue => e
result = "ServiceNow-#{line.address}" Rails.logger.info "Unable to parse email address in '#{from}': #{e.message}"
break
end
rescue
Rails.logger.info "Unable to parse email address in '#{from}'"
end
result
end end
def self.from_sync_entry(mail:, source_name:, source_id:) 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 it 'adds Article to existing Ticket' do
expect { described_class.new.process({}, raw_mail) }.to change { ticket.reload.articles.count } expect { described_class.new.process({}, raw_mail) }.to change { ticket.reload.articles.count }
end 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
end end