This commit is contained in:
parent
fc987d7bcb
commit
89f99e52dd
2 changed files with 44 additions and 18 deletions
|
@ -1017,23 +1017,12 @@ perform changes on ticket
|
||||||
save!
|
save!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
objects = build_notification_template_objects(article)
|
||||||
|
|
||||||
perform_article.each do |key, value|
|
perform_article.each do |key, value|
|
||||||
raise 'Unable to create article, we only support article.note' if key != 'article.note'
|
raise 'Unable to create article, we only support article.note' if key != 'article.note'
|
||||||
|
|
||||||
Ticket::Article.create!(
|
add_trigger_note(id, value, objects, perform_origin)
|
||||||
ticket_id: id,
|
|
||||||
subject: value[:subject],
|
|
||||||
content_type: 'text/html',
|
|
||||||
body: value[:body],
|
|
||||||
internal: value[:internal],
|
|
||||||
sender: Ticket::Article::Sender.find_by(name: 'System'),
|
|
||||||
type: Ticket::Article::Type.find_by(name: 'note'),
|
|
||||||
preferences: {
|
|
||||||
perform_origin: perform_origin,
|
|
||||||
},
|
|
||||||
updated_by_id: 1,
|
|
||||||
created_by_id: 1,
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
perform_notification.each do |key, value|
|
perform_notification.each do |key, value|
|
||||||
|
@ -1053,6 +1042,43 @@ perform changes on ticket
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
|
perform changes on ticket
|
||||||
|
|
||||||
|
ticket.add_trigger_note(ticket_id, note, objects, perform_origin)
|
||||||
|
|
||||||
|
=end
|
||||||
|
|
||||||
|
def add_trigger_note(ticket_id, note, objects, perform_origin)
|
||||||
|
rendered_subject = NotificationFactory::Mailer.template(
|
||||||
|
templateInline: note[:subject],
|
||||||
|
objects: objects,
|
||||||
|
quote: true,
|
||||||
|
)
|
||||||
|
|
||||||
|
rendered_body = NotificationFactory::Mailer.template(
|
||||||
|
templateInline: note[:body],
|
||||||
|
objects: objects,
|
||||||
|
quote: true,
|
||||||
|
)
|
||||||
|
|
||||||
|
Ticket::Article.create!(
|
||||||
|
ticket_id: ticket_id,
|
||||||
|
subject: rendered_subject,
|
||||||
|
content_type: 'text/html',
|
||||||
|
body: rendered_body,
|
||||||
|
internal: note[:internal],
|
||||||
|
sender: Ticket::Article::Sender.find_by(name: 'System'),
|
||||||
|
type: Ticket::Article::Type.find_by(name: 'note'),
|
||||||
|
preferences: {
|
||||||
|
perform_origin: perform_origin,
|
||||||
|
},
|
||||||
|
updated_by_id: 1,
|
||||||
|
created_by_id: 1,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
=begin
|
||||||
|
|
||||||
perform active triggers on ticket
|
perform active triggers on ticket
|
||||||
|
|
||||||
Ticket.perform_triggers(ticket, article, item, options)
|
Ticket.perform_triggers(ticket, article, item, options)
|
||||||
|
|
|
@ -4446,8 +4446,8 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
||||||
},
|
},
|
||||||
perform: {
|
perform: {
|
||||||
'article.note' => {
|
'article.note' => {
|
||||||
'body' => 'some note',
|
'subject' => 'some subject! #{ticket.id}',
|
||||||
'subject' => 'some subject!',
|
'body' => 'I can integrate with 3rd party services at https://my.saas/foo/#{ticket.id}',
|
||||||
'internal' => 'true',
|
'internal' => 'true',
|
||||||
},
|
},
|
||||||
'notification.email' => {
|
'notification.email' => {
|
||||||
|
@ -4508,8 +4508,8 @@ class TicketTriggerTest < ActiveSupport::TestCase
|
||||||
article_note1 = ticket1.articles[1]
|
article_note1 = ticket1.articles[1]
|
||||||
assert_match('- ', article_note1.from)
|
assert_match('- ', article_note1.from)
|
||||||
assert_nil(article_note1.to)
|
assert_nil(article_note1.to)
|
||||||
assert_match('some subject!', article_note1.subject)
|
assert_match("some subject! #{ticket1.id}", article_note1.subject)
|
||||||
assert_match('some note', article_note1.body)
|
assert_match("I can integrate with 3rd party services at <a href=\"https://my.saas/foo/#{ticket1.id}\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">https://my.saas/foo/#{ticket1.id}</a>", article_note1.body)
|
||||||
assert_equal('text/html', article_note1.content_type)
|
assert_equal('text/html', article_note1.content_type)
|
||||||
assert_equal(true, article_note1.internal)
|
assert_equal(true, article_note1.internal)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue