mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-13 16:52:23 -05:00
Ignore case and whitespace in personalisation keys
From a support ticket:
> it's possible to add a personalisation token with trailing whitespace
> (eg. "key " rather than "key"). Can this be trimmed in the UI to guard
> against this? (one of our devs copied and pasted it from a document
> and inadvertently included the space)
> Nothing major but caused a few hours of investigations!
Rather than trim the placeholder in the template, we should treat
placeholders in API calls the same way we do with CSV files, ie we
ignore case and spacing in the name of the placeholder. So
`(( First Name))` is equivalent to `((first_name))`, and both would be
populated with a dictionary like `{'firstName': 'Chris'}`.
Depends on:
- [x] https://github.com/alphagov/notifications-utils/pull/77
This commit is contained in:
@@ -72,10 +72,7 @@ def process_job(job_id):
|
||||
'job': str(job.id),
|
||||
'to': recipient,
|
||||
'row_number': row_number,
|
||||
'personalisation': {
|
||||
key: personalisation.get(key)
|
||||
for key in template.placeholders
|
||||
}
|
||||
'personalisation': dict(personalisation)
|
||||
})
|
||||
|
||||
if template.template_type == SMS_TYPE:
|
||||
|
||||
Reference in New Issue
Block a user