Fix global SEND_DEFAULTS merging

Replace generic `combine` with
specific `merge_dicts_deep`,
`merge_dicts_shallow`,
`merge_dicts_one_level` or
`concat_lists`, depending on
appropriate behavior for each
message attribute.

Fixes merging global `SEND_DEFAULTS`
with message `esp_extra` for ESP APIs
that use nested payload structures.
And clarifies intent for other properties.
This commit is contained in:
Mike Edmunds
2023-10-19 14:27:35 -07:00
parent f911ee78a0
commit 823a161927
6 changed files with 271 additions and 39 deletions

View File

@@ -21,8 +21,8 @@ from ..signals import (
)
from ..utils import (
UNSET,
combine,
get_anymail_setting,
merge_dicts_shallow,
parse_single_address,
querydict_getfirst,
)
@@ -341,7 +341,9 @@ class MailgunTrackingWebhookView(MailgunBaseWebhookView):
if len(variables) >= 1:
# Each X-Mailgun-Variables value is JSON. Parse and merge them all into
# single dict:
metadata = combine(*[json.loads(value) for value in variables])
metadata = merge_dicts_shallow(
*[json.loads(value) for value in variables]
)
elif event_type in self._known_legacy_event_fields:
# For other events, we must extract from the POST fields, ignoring known