Fixes #3894 - Follow-up detection does not work for the body of plain text mails.

This commit is contained in:
Florian Liebe 2022-06-09 14:24:13 +02:00
parent 7279cb88b5
commit 927ecff993
2 changed files with 18 additions and 1 deletions

View file

@ -18,7 +18,10 @@ module Channel::Filter::FollowUpCheck
# get ticket# from body # get ticket# from body
if setting.include?('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 if ticket
Rails.logger.debug { "Follow-up for '##{ticket.number}' in body." } Rails.logger.debug { "Follow-up for '##{ticket.number}' in body." }
mail[:'x-zammad-ticket-id'] = ticket.id mail[:'x-zammad-ticket-id'] = ticket.id

View file

@ -632,6 +632,20 @@ RSpec.describe Channel::EmailParser, type: :model do
include_examples 'adds message to ticket' include_examples 'adds message to ticket'
end 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 context 'as part of a larger word' do
let(:ticket_ref) { "Foo#{Setting.get('ticket_hook')}#{Setting.get('ticket_hook_divider')}#{ticket.number}bar" } let(:ticket_ref) { "Foo#{Setting.get('ticket_hook')}#{Setting.get('ticket_hook_divider')}#{ticket.number}bar" }