mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-21 16:01:15 -05:00
fix personalisation for emails
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
|
import json
|
||||||
import os
|
import os
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
from sqlalchemy.orm.exc import NoResultFound
|
from sqlalchemy.orm.exc import NoResultFound
|
||||||
|
|
||||||
from app import aws_cloudwatch_client, notify_celery
|
from app import aws_cloudwatch_client, notify_celery, redis_store
|
||||||
from app.clients.email import EmailClientNonRetryableException
|
from app.clients.email import EmailClientNonRetryableException
|
||||||
from app.clients.email.aws_ses import AwsSesClientThrottlingSendRateException
|
from app.clients.email.aws_ses import AwsSesClientThrottlingSendRateException
|
||||||
from app.clients.sms import SmsClientResponseException
|
from app.clients.sms import SmsClientResponseException
|
||||||
@@ -162,8 +163,12 @@ def deliver_email(self, notification_id):
|
|||||||
"Start sending email for notification id: {}".format(notification_id)
|
"Start sending email for notification id: {}".format(notification_id)
|
||||||
)
|
)
|
||||||
notification = notifications_dao.get_notification_by_id(notification_id)
|
notification = notifications_dao.get_notification_by_id(notification_id)
|
||||||
|
|
||||||
if not notification:
|
if not notification:
|
||||||
raise NoResultFound()
|
raise NoResultFound()
|
||||||
|
personalisation = redis_store.get(f"email-personalisation-{notification_id}")
|
||||||
|
|
||||||
|
notification.personalisation = json.loads(personalisation)
|
||||||
send_to_providers.send_email_to_provider(notification)
|
send_to_providers.send_email_to_provider(notification)
|
||||||
except EmailClientNonRetryableException as e:
|
except EmailClientNonRetryableException as e:
|
||||||
current_app.logger.exception(
|
current_app.logger.exception(
|
||||||
|
|||||||
@@ -437,6 +437,11 @@ def send_new_user_email_verification(user_id):
|
|||||||
str(user_to_send_to.email_address),
|
str(user_to_send_to.email_address),
|
||||||
ex=60 * 60,
|
ex=60 * 60,
|
||||||
)
|
)
|
||||||
|
redis_store.set(
|
||||||
|
f"email-personalisation-{saved_notification.id}",
|
||||||
|
json.dumps(personalisation),
|
||||||
|
ex=60 * 60,
|
||||||
|
)
|
||||||
current_app.logger.info("Sending notification to queue")
|
current_app.logger.info("Sending notification to queue")
|
||||||
|
|
||||||
send_notification_to_queue(saved_notification, queue=QueueNames.NOTIFY)
|
send_notification_to_queue(saved_notification, queue=QueueNames.NOTIFY)
|
||||||
|
|||||||
Reference in New Issue
Block a user