Quietly ignore extra personalisation

> If a user makes an API request with additional personalisation fields,
> we should simply discard any fields that the template doesn't have.
>
> This gives a couple of related advantages:
>
> - modifying template parameters no longer requires downtime for
>   clients - as they can pass in extra new parameters before a template
>   change, or continue passing in old unused parameters after removing
>   them from a template
>
> - services can pass in large user objects, for example, and then play
>   around with templates adding and removing fields at will
>
> we should make sure we still return an error if a user doesn't pass in
> a required parameter.

– https://www.pivotaltracker.com/story/show/140774195
This commit is contained in:
Chris Hill-Scott
2017-03-07 16:03:10 +00:00
parent b0d5def289
commit e507fed152
6 changed files with 7 additions and 27 deletions

View File

@@ -300,11 +300,6 @@ def create_template_object_for_notification(template, personalisation):
errors = {'template': [message]}
raise InvalidRequest(errors, status_code=400)
if template_object.additional_data:
message = 'Personalisation not needed for template: {}'.format(", ".join(template_object.additional_data))
errors = {'template': [message]}
raise InvalidRequest(errors, status_code=400)
if (
template_object.template_type == SMS_TYPE and
template_object.content_count > current_app.config.get('SMS_CHAR_COUNT_LIMIT')