diff --git a/app/models/channel/filter/follow_up_check.rb b/app/models/channel/filter/follow_up_check.rb index 93f450cd3..c1d8d53d1 100644 --- a/app/models/channel/filter/follow_up_check.rb +++ b/app/models/channel/filter/follow_up_check.rb @@ -18,7 +18,10 @@ module Channel::Filter::FollowUpCheck # get ticket# from body if setting.include?('body') - ticket = Ticket::Number.check(mail[:body].html2text) + body = mail[:body] + body = body.html2text if mail[:content_type] == 'text/html' + + ticket = Ticket::Number.check(body) if ticket Rails.logger.debug { "Follow-up for '##{ticket.number}' in body." } mail[:'x-zammad-ticket-id'] = ticket.id diff --git a/spec/models/channel/email_parser_spec.rb b/spec/models/channel/email_parser_spec.rb index 08d32c975..9550ff98c 100644 --- a/spec/models/channel/email_parser_spec.rb +++ b/spec/models/channel/email_parser_spec.rb @@ -632,6 +632,20 @@ RSpec.describe Channel::EmailParser, type: :model do include_examples 'adds message to ticket' end + context 'in visible text with a linebreak' do + let(:raw_mail) { <<~RAW.chomp } + From: me@example.com + To: customer@example.com + Subject: no reference + + Lorem ipsum dolor #{ticket_ref} + consetetur sadipscing elitr + sed diam nonumy eirmod + RAW + + include_examples 'adds message to ticket' + end + context 'as part of a larger word' do let(:ticket_ref) { "Foo#{Setting.get('ticket_hook')}#{Setting.get('ticket_hook_divider')}#{ticket.number}bar" }