fix personalisation for emails

This commit is contained in:
Kenneth Kehl
2024-03-06 10:28:34 -08:00
parent a8dcda4c55
commit 492daee970
2 changed files with 11 additions and 1 deletions

View File

@@ -1,10 +1,11 @@
import json
import os
from datetime import datetime, timedelta
from flask import current_app
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.aws_ses import AwsSesClientThrottlingSendRateException
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)
)
notification = notifications_dao.get_notification_by_id(notification_id)
if not notification:
raise NoResultFound()
personalisation = redis_store.get(f"email-personalisation-{notification_id}")
notification.personalisation = json.loads(personalisation)
send_to_providers.send_email_to_provider(notification)
except EmailClientNonRetryableException as e:
current_app.logger.exception(

View File

@@ -437,6 +437,11 @@ def send_new_user_email_verification(user_id):
str(user_to_send_to.email_address),
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")
send_notification_to_queue(saved_notification, queue=QueueNames.NOTIFY)