Start using config ticket_subject_re for reply emails.

This commit is contained in:
Martin Edenhofer 2016-05-23 19:56:39 +02:00
parent 7cf884c7a4
commit 0e150fccd0
3 changed files with 33 additions and 5 deletions

View file

@ -8,7 +8,12 @@ class Observer::Ticket::Article::CommunicateEmail::BackgroundJob
# build subject # build subject
ticket = Ticket.lookup(id: record.ticket_id) ticket = Ticket.lookup(id: record.ticket_id)
subject = ticket.subject_build(record.subject) article_count = Ticket::Article.where(ticket_id: ticket.id).count
subject = if article_count > 1
ticket.subject_build(record.subject, true)
else
ticket.subject_build(record.subject)
end
# send email # send email
if !ticket.group.email_address_id if !ticket.group.email_address_id

View file

@ -6,7 +6,7 @@ module Ticket::Subject
build new subject with ticket number in there build new subject with ticket number in there
ticket = Ticket.find(123) ticket = Ticket.find(123)
result = ticket.subject_build('some subject') result = ticket.subject_build('some subject', is_reply_true_false)
returns returns
@ -14,13 +14,17 @@ returns
=end =end
def subject_build (subject) def subject_build(subject, is_reply = false)
# clena subject # clena subject
subject = subject_clean(subject) subject = subject_clean(subject)
ticket_hook = Setting.get('ticket_hook') ticket_hook = Setting.get('ticket_hook')
ticket_hook_divider = Setting.get('ticket_hook_divider') ticket_hook_divider = Setting.get('ticket_hook_divider')
ticket_subject_re = Setting.get('ticket_subject_re')
if is_reply && !ticket_subject_re.empty?
subject = "#{ticket_subject_re}: #{subject}"
end
# none position # none position
if Setting.get('ticket_hook_position') == 'none' if Setting.get('ticket_hook_position') == 'none'

View file

@ -263,4 +263,23 @@ class TicketTest < ActiveSupport::TestCase
lookup_ticket = Ticket.find_by('pending_time <= ?', Time.zone.now) lookup_ticket = Ticket.find_by('pending_time <= ?', Time.zone.now)
assert_nil(lookup_ticket, 'ticket.pending_time processed verify') assert_nil(lookup_ticket, 'ticket.pending_time processed verify')
end end
test 'ticket subject' do
ticket1 = Ticket.create(
title: 'subject test 1',
group: Group.lookup(name: 'Users'),
customer_id: 2,
state: Ticket::State.lookup(name: 'new'),
priority: Ticket::Priority.lookup(name: '2 normal'),
updated_by_id: 1,
created_by_id: 1,
)
assert_equal('subject test 1', ticket1.title)
assert_equal("ABC subject test 1 [Ticket##{ticket1.number}]", ticket1.subject_build('ABC subject test 1'))
assert_equal("RE: ABC subject test 1 [Ticket##{ticket1.number}]", ticket1.subject_build('ABC subject test 1', true))
ticket1.destroy
end
end end