store api_key_id and key_type on notification

pass through from POST /notification/<type> to the celery task
also removed a couple of asserts that can fail (based on unfrozen time comparisons)
This commit is contained in:
Leo Hemsted
2016-06-30 17:32:49 +01:00
parent 5ae7ed1acb
commit 01419e7894
4 changed files with 115 additions and 58 deletions

View File

@@ -267,19 +267,33 @@ def send_notification(notification_type):
notification_id = create_uuid()
notification.update({"template_version": template.version})
if notification_type == SMS_TYPE:
send_sms.apply_async((
service_id,
notification_id,
encryption.encrypt(notification),
datetime.utcnow().strftime(DATETIME_FORMAT)
), queue='sms')
send_sms.apply_async(
(
service_id,
notification_id,
encryption.encrypt(notification),
datetime.utcnow().strftime(DATETIME_FORMAT)
),
kwargs={
'api_key_id': str(api_user.id),
'key_type': api_user.key_type
},
queue='sms'
)
else:
send_email.apply_async((
service_id,
notification_id,
encryption.encrypt(notification),
datetime.utcnow().strftime(DATETIME_FORMAT)
), queue='email')
send_email.apply_async(
(
service_id,
notification_id,
encryption.encrypt(notification),
datetime.utcnow().strftime(DATETIME_FORMAT)
),
kwargs={
'api_key_id': str(api_user.id),
'key_type': api_user.key_type
},
queue='email'
)
statsd_client.incr('notifications.api.{}'.format(notification_type))
return jsonify(