diff --git a/app/models/channel/filter/identify_sender.rb b/app/models/channel/filter/identify_sender.rb index 99a98bfae..71634cffe 100644 --- a/app/models/channel/filter/identify_sender.rb +++ b/app/models/channel/filter/identify_sender.rb @@ -87,6 +87,8 @@ module Channel::Filter::IdentifySender # create to and cc user def self.create_recipients(mail) + max_count = 40 + current_count = 0 ['raw-to', 'raw-cc'].each { |item| next if !mail[item.to_sym] begin @@ -99,6 +101,8 @@ module Channel::Filter::IdentifySender lastname: '', email: address_data.address, ) + current_count += 1 + return false if current_count == max_count } rescue => e # parse not parseable fields by mail gem like @@ -122,6 +126,8 @@ module Channel::Filter::IdentifySender lastname: '', email: address, ) + current_count += 1 + return false if current_count == max_count } end } diff --git a/test/unit/email_process_identify_sender_max_test.rb b/test/unit/email_process_identify_sender_max_test.rb new file mode 100644 index 000000000..f431c6c52 --- /dev/null +++ b/test/unit/email_process_identify_sender_max_test.rb @@ -0,0 +1,35 @@ +# encoding: utf-8 +require 'test_helper' + +class EmailProcessIdentifySenderMax < ActiveSupport::TestCase + + test 'text max created recipients per email' do + current_users = User.count + email_raw_string = "From: customer@example.com +To: #{generate_recipient(22)} +Cc: #{generate_recipient(22)} +Subject: test max sender identify + +Some Text" + + ticket_p, article_p, user_p, mail = Channel::EmailParser.new.process({}, email_raw_string) + ticket = Ticket.find(ticket_p.id) + assert_equal('test max sender identify', ticket.title) + + assert_equal(current_users + 40, User.count) + end + + def generate_recipient(count) + recipients = '' + count.times.each do + if recipients.present? + recipients += ', ' + end + domain = "#{Time.zone.now.to_i}-#{rand(999_999_999)}.example.com" + email = "#{Time.zone.now.to_i}-#{rand(999_999_999)}@#{domain}" + recipients += email + end + recipients + end + +end