FIX: use metadata to hold the message_id with sparkpost
This commit is contained in:
parent
407cda1dfe
commit
71f940d478
|
@ -91,7 +91,7 @@ class WebhooksController < ActionController::Base
|
||||||
def sparkpost
|
def sparkpost
|
||||||
events = params["_json"] || [params]
|
events = params["_json"] || [params]
|
||||||
events.each do |event|
|
events.each do |event|
|
||||||
message_id = event["msys"]["message_event"]["message_id"] rescue nil
|
message_id = event["msys"]["message_event"]["rcpt_meta"]["message_id"] rescue nil
|
||||||
bounce_class = event["msys"]["message_event"]["bounce_class"] rescue nil
|
bounce_class = event["msys"]["message_event"]["bounce_class"] rescue nil
|
||||||
next unless message_id && bounce_class
|
next unless message_id && bounce_class
|
||||||
|
|
||||||
|
|
|
@ -133,12 +133,14 @@ module Email
|
||||||
@message.header['X-Discourse-Post-Id'] = nil if post_id.present?
|
@message.header['X-Discourse-Post-Id'] = nil if post_id.present?
|
||||||
@message.header['X-Discourse-Reply-Key'] = nil if reply_key.present?
|
@message.header['X-Discourse-Reply-Key'] = nil if reply_key.present?
|
||||||
|
|
||||||
# pass the original message_id when using mailjet/mandrill
|
# pass the original message_id when using mailjet/mandrill/sparkpost
|
||||||
case ActionMailer::Base.smtp_settings[:address]
|
case ActionMailer::Base.smtp_settings[:address]
|
||||||
when /\.mailjet\.com/
|
when /\.mailjet\.com/
|
||||||
@message.header['X-MJ-CustomID'] = @message.message_id
|
@message.header['X-MJ-CustomID'] = @message.message_id
|
||||||
when "smtp.mandrillapp.com"
|
when "smtp.mandrillapp.com"
|
||||||
@message.header['X-MC-Metadata'] = { message_id: @message.message_id }.to_json
|
@message.header['X-MC-Metadata'] = { message_id: @message.message_id }.to_json
|
||||||
|
when "smtp.sparkpostmail.com"
|
||||||
|
@message.header['X-MSYS-API'] = { metadata: { message_id: @message.message_id } }.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
# Suppress images from short emails
|
# Suppress images from short emails
|
||||||
|
|
|
@ -109,7 +109,9 @@ describe WebhooksController do
|
||||||
"msys" => {
|
"msys" => {
|
||||||
"message_event" => {
|
"message_event" => {
|
||||||
"bounce_class" => 10,
|
"bounce_class" => 10,
|
||||||
"message_id" => message_id
|
"rcpt_meta" => {
|
||||||
|
"message_id" => message_id
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
|
|
Loading…
Reference in New Issue