Fix sequential execution of multiple email notification triggers
This commit is contained in:
parent
b057155832
commit
03c586e7fc
1 changed files with 14 additions and 11 deletions
|
@ -806,6 +806,10 @@ perform changes on ticket
|
|||
def perform_changes(perform, perform_origin, item = nil, current_user_id = nil)
|
||||
logger.debug { "Perform #{perform_origin} #{perform.inspect} on Ticket.find(#{id})" }
|
||||
|
||||
article = if item.try(:key?, :article_id)
|
||||
Ticket::Article.lookup(id: item[:article_id])
|
||||
end
|
||||
|
||||
# if the configuration contains the deletion of the ticket then
|
||||
# we skip all other ticket changes because they does not matter
|
||||
if perform['ticket.action'].present? && perform['ticket.action']['value'] == 'delete'
|
||||
|
@ -835,8 +839,7 @@ perform changes on ticket
|
|||
recipients_raw = []
|
||||
value_recipient.each do |recipient|
|
||||
if recipient == 'article_last_sender'
|
||||
if item && item[:article_id]
|
||||
article = Ticket::Article.lookup(id: item[:article_id])
|
||||
if article.present?
|
||||
if article.reply_to.present?
|
||||
recipients_raw.push(article.reply_to)
|
||||
elsif article.from.present?
|
||||
|
@ -914,13 +917,10 @@ perform changes on ticket
|
|||
end
|
||||
|
||||
# check if notification should be send because of customer emails
|
||||
if item && item[:article_id]
|
||||
article = Ticket::Article.lookup(id: item[:article_id])
|
||||
if article&.preferences&.fetch('is-auto-response', false) == true && article.from && article.from =~ /#{Regexp.quote(recipient_email)}/i
|
||||
if article.present? && article.preferences.fetch('is-auto-response', false) == true && article.from && article.from =~ /#{Regexp.quote(recipient_email)}/i
|
||||
logger.info "Send no trigger based notification to #{recipient_email} because of auto response tagged incoming email"
|
||||
next
|
||||
end
|
||||
end
|
||||
|
||||
# loop protection / check if maximal count of trigger mail has reached
|
||||
map = {
|
||||
|
@ -984,9 +984,12 @@ perform changes on ticket
|
|||
next
|
||||
end
|
||||
|
||||
# articles.last breaks (returns the wrong article)
|
||||
# if another email notification trigger preceded this one
|
||||
# (see https://github.com/zammad/zammad/issues/1543)
|
||||
objects = {
|
||||
ticket: self,
|
||||
article: articles.last,
|
||||
article: article || articles.last
|
||||
}
|
||||
|
||||
# get subject
|
||||
|
@ -1007,7 +1010,7 @@ perform changes on ticket
|
|||
|
||||
(body, attachments_inline) = HtmlSanitizer.replace_inline_images(body, id)
|
||||
|
||||
article = Ticket::Article.create(
|
||||
message = Ticket::Article.create(
|
||||
ticket_id: id,
|
||||
to: recipient_string,
|
||||
subject: subject,
|
||||
|
@ -1026,7 +1029,7 @@ perform changes on ticket
|
|||
attachments_inline.each do |attachment|
|
||||
Store.add(
|
||||
object: 'Ticket::Article',
|
||||
o_id: article.id,
|
||||
o_id: message.id,
|
||||
data: attachment[:data],
|
||||
filename: attachment[:filename],
|
||||
preferences: attachment[:preferences],
|
||||
|
|
Loading…
Reference in a new issue