Added support of references header in outgoing emails.

This commit is contained in:
Martin Edenhofer 2015-12-11 15:11:34 +01:00
parent 921d247dec
commit 6ad0245db6
2 changed files with 27 additions and 4 deletions

View file

@ -40,7 +40,11 @@ module Channel::EmailBuild
next if key.to_s == 'attachments' next if key.to_s == 'attachments'
next if key.to_s == 'body' next if key.to_s == 'body'
next if key.to_s == 'content_type' next if key.to_s == 'content_type'
mail[key.to_s] = value.to_s if value && value.class != Array
mail[key.to_s] = value.to_s
else
mail[key.to_s] = value
end
end end
# add html part # add html part

View file

@ -4,11 +4,11 @@ class Observer::Ticket::Article::CommunicateEmail::BackgroundJob
end end
def perform def perform
record = Ticket::Article.find( @article_id ) record = Ticket::Article.find(@article_id)
# build subject # build subject
ticket = Ticket.lookup( id: record.ticket_id ) ticket = Ticket.lookup(id: record.ticket_id)
subject = ticket.subject_build( record.subject ) subject = ticket.subject_build(record.subject)
# send email # send email
if !ticket.group.email_address_id if !ticket.group.email_address_id
@ -16,6 +16,24 @@ class Observer::Ticket::Article::CommunicateEmail::BackgroundJob
elsif !ticket.group.email_address.channel_id elsif !ticket.group.email_address.channel_id
fail "Can't send email, no channel definde for email_address id '#{ticket.group.email_address_id}'" fail "Can't send email, no channel definde for email_address id '#{ticket.group.email_address_id}'"
end end
# get references headers
references = []
if record.in_reply_to
references.push record.in_reply_to
end
# add all other article message_ids
Ticket::Article.where(ticket_id: record.ticket_id).each {|article|
if article.in_reply_to && !article.in_reply_to.empty?
references.push article.in_reply_to
end
next if !article.message_id
next if !article.message_id.empty?
next if article.id == @article_id
references.push article.message_id
}
channel = ticket.group.email_address.channel channel = ticket.group.email_address.channel
# get linked channel and send # get linked channel and send
@ -23,6 +41,7 @@ class Observer::Ticket::Article::CommunicateEmail::BackgroundJob
{ {
message_id: record.message_id, message_id: record.message_id,
in_reply_to: record.in_reply_to, in_reply_to: record.in_reply_to,
references: references,
from: record.from, from: record.from,
to: record.to, to: record.to,
cc: record.cc, cc: record.cc,