Improved ticket follow up detection if more T#'s in subject.

This commit is contained in:
Martin Edenhofer 2016-03-16 10:36:51 +01:00
parent 4a77b273e5
commit c0eae369d6
3 changed files with 81 additions and 27 deletions

View file

@ -73,10 +73,15 @@ module Ticket::Number::Date
ticket = nil
# probe format
if string =~ /#{ticket_hook}#{ticket_hook_divider}(#{system_id}\d{2,50})/i
string.scan(/#{ticket_hook}#{ticket_hook_divider}(#{system_id}\d{2,48})/i) {
ticket = Ticket.find_by(number: $1)
elsif string =~ /#{ticket_hook}\s{0,2}(#{system_id}\d{2,50})/i
break if ticket
}
if !ticket
string.scan(/#{ticket_hook}\s{0,2}(#{system_id}\d{2,48})/i) {
ticket = Ticket.find_by(number: $1)
break if ticket
}
end
ticket
end

View file

@ -78,10 +78,15 @@ module Ticket::Number::Increment
ticket = nil
# probe format
if string =~ /#{ticket_hook}#{ticket_hook_divider}(#{system_id}\d{2,48})/i
string.scan(/#{ticket_hook}#{ticket_hook_divider}(#{system_id}\d{2,48})/i) {
ticket = Ticket.find_by(number: $1)
elsif string =~ /#{ticket_hook}\s{0,2}(#{system_id}\d{2,48})/i
break if ticket
}
if !ticket
string.scan(/#{ticket_hook}\s{0,2}(#{system_id}\d{2,48})/i) {
ticket = Ticket.find_by(number: $1)
break if ticket
}
end
ticket
end

View file

@ -171,4 +171,48 @@ Some Text"
assert_equal('open', ticket.state.name)
end
test 'process with follow up check - email with more forgein T#\'s in subject' do
ticket = Ticket.create(
title: 'email with more forgein T#\'s in subject',
group: Group.lookup(name: 'Users'),
customer_id: 2,
state: Ticket::State.lookup(name: 'closed'),
priority: Ticket::Priority.lookup(name: '2 normal'),
updated_by_id: 1,
created_by_id: 1,
)
article = Ticket::Article.create(
ticket_id: ticket.id,
from: 'some_sender@example.com',
to: 'some_recipient@example.com',
subject: 'follow up with references follow up check',
message_id: '<20151222145601.30.608881@edenhofer.zammad.com>',
body: 'some message with references follow up check',
internal: false,
sender: Ticket::Article::Sender.lookup(name: 'Agent'),
type: Ticket::Article::Type.lookup(name: 'email'),
updated_by_id: 1,
created_by_id: 1,
)
sleep 1
system_id = Setting.get('system_id')
ticket_hook = Setting.get('ticket_hook')
ticket_hook_divider = Setting.get('ticket_hook_divider')
tn = "[#{ticket_hook}#{ticket_hook_divider}#{system_id}#{Ticket::Number.generate}99]"
email_raw_string_subject = "From: me@example.com
To: customer@example.com
Subject: First foreign Tn #{tn} #{tn} #{tn} - #{ticket.subject_build('some new subject')}
Some Text"
ticket_p, article_p, user_p, mail = Channel::EmailParser.new.process({}, email_raw_string_subject)
ticket = Ticket.find(ticket.id)
assert_equal(ticket.id, ticket_p.id)
assert_equal('open', ticket.state.name)
end
end