Skip to content

Commit

Permalink
Change merge_headers to dict of dicts
Browse files Browse the repository at this point in the history
  • Loading branch information
carrerasrodrigo authored and medmunds committed May 21, 2024
1 parent 88f4443 commit be3a980
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
5 changes: 4 additions & 1 deletion anymail/backends/amazon_ses.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,10 @@ def finalize_payload(self):
}

if len(self.merge_headers) > 0:
entry["ReplacementHeaders"] = self.merge_headers.get(to.addr_spec, [])
entry["ReplacementHeaders"] = [
{"Name": key, "Value": value}
for key, value in self.merge_headers.get(to.addr_spec, {}).items()
]
self.params["BulkEmailEntries"].append(entry)

def parse_recipient_status(self, response):
Expand Down
24 changes: 12 additions & 12 deletions tests/test_amazon_ses_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,17 +654,14 @@ def test_template(self):
"[email protected]": {"name": "Not a recipient for this message"},
},
merge_headers={
"[email protected]": [
{"Name": "List-Unsubscribe", "Value": "<https://example.com/a/>"},
{"List-Unsubscribe-Post": "List-Unsubscribe=One-Click"},
],
"[email protected]": [
{
"Name": "List-Unsubscribe",
"Value": "<mailto:[email protected]>",
},
{"List-Unsubscribe-Post": "List-Unsubscribe=One-Click"},
],
"[email protected]": {
"List-Unsubscribe": "<https://example.com/a/>",
"List-Unsubscribe-Post": "List-Unsubscribe=One-Click",
},
"[email protected]": {
"List-Unsubscribe": "<mailto:[email protected]>",
"List-Unsubscribe-Post": "List-Unsubscribe=One-Click",
},
},
merge_global_data={"group": "Users", "site": "ExampleCo"},
# (only works with AMAZON_SES_MESSAGE_TAG_NAME when using template):
Expand Down Expand Up @@ -722,7 +719,10 @@ def test_template(self):
bulk_entries[0]["ReplacementHeaders"],
[
{"Name": "List-Unsubscribe", "Value": "<https://example.com/a/>"},
{"List-Unsubscribe-Post": "List-Unsubscribe=One-Click"},
{
"Name": "List-Unsubscribe-Post",
"Value": "List-Unsubscribe=One-Click",
},
],
)
self.assertEqual(
Expand Down

0 comments on commit be3a980

Please sign in to comment.