FIX: issues with 'X-MSYS-API' custom header

This commit is contained in:
Régis Hanol 2016-11-03 02:26:12 +01:00
parent 847eea85a0
commit 17169b3037

View File

@ -203,11 +203,16 @@ module Email
end
def merge_json_x_header(name, value)
mc_metadata = JSON.parse(@message.header[name].to_s) rescue nil
mc_metadata ||= {}
mc_metadata.merge!(value)
data = JSON.parse(@message.header[name].to_s) rescue nil
data ||= {}
data.merge!(value)
# /!\ @message.header is not a standard ruby hash.
# It can have multiple values attached to the same key...
# In order to remove all the previous keys, we have to "nil" it.
# But for "nil" to work, there must already be a key...
@message.header[name] = ""
@message.header[name] = nil
@message.header[name] = mc_metadata.to_json
@message.header[name] = data.to_json
end
end