ensure we're passing through api keys and key types from notifications

when we made the change to async persist notifications, we forgot to
pass through api_key_id and key_type. in send_sms/email, for legacy
reasons, they default to None/KEY_TYPE_NORMAL, so regardless of what
your api key was set up as, we would send real messages!

TODO: Once the PaaS transition is complete and the task changes are
reverted, remove the api_key_id and key_type params from the send_*
tasks entirely, as those are only called from the csv job flow, and
don't need them
This commit is contained in:
Leo Hemsted
2017-03-28 13:14:46 +01:00
parent d5f8b4d80b
commit 25d1777937
4 changed files with 85 additions and 20 deletions

View File

@@ -124,7 +124,14 @@ def process_row(row_number, recipient, personalisation, template, job, service):
def send_notification_to_persist_queue(
notification_id, service, template_type, encrypted, priority=False, research_mode=False
notification_id,
service,
template_type,
encrypted,
api_key_id,
key_type,
priority=False,
research_mode=False
):
queues = {
SMS_TYPE: 'db-sms',
@@ -150,8 +157,12 @@ def send_notification_to_persist_queue(
str(service.id),
notification_id,
encrypted,
datetime.utcnow().strftime(DATETIME_FORMAT)
datetime.utcnow().strftime(DATETIME_FORMAT),
),
kwargs={
'api_key_id': api_key_id,
'key_type': key_type
},
queue=queue_name
)

View File

@@ -147,12 +147,14 @@ def send_notification(notification_type):
if not simulated:
tasks.send_notification_to_persist_queue(
notification_model.id,
service,
template.template_type,
encrypted,
template.process_type == PRIORITY,
service.research_mode or api_user.key_type == KEY_TYPE_TEST
notification_id=notification_model.id,
service=service,
template_type=template.template_type,
encrypted=encrypted,
api_key_id=str(notification_model.api_key_id),
key_type=api_user.key_type,
priority=template.process_type == PRIORITY,
research_mode=service.research_mode or api_user.key_type == KEY_TYPE_TEST
)
# queue_name = 'notify' if template.process_type == PRIORITY else None
# send_notification_to_queue(notification=notification_model,

View File

@@ -68,12 +68,14 @@ def post_notification(notification_type):
if not simulated:
tasks.send_notification_to_persist_queue(
notification.id,
service,
template.template_type,
encrypted,
template.process_type == PRIORITY,
service.research_mode or api_user.key_type == KEY_TYPE_TEST
notification_id=notification.id,
service=service,
template_type=template.template_type,
encrypted=encrypted,
api_key_id=str(notification.api_key_id),
key_type=api_user.key_type,
priority=template.process_type == PRIORITY,
research_mode=service.research_mode or api_user.key_type == KEY_TYPE_TEST
)
# not doing this during paas migration
# queue_name = 'notify' if template.process_type == PRIORITY else None