Insert a row for the mapping of notification to email_reply_to for one off notifications.

This commit is contained in:
Rebecca Law
2017-10-11 16:23:31 +01:00
parent 04914d711a
commit 769a7a275b
3 changed files with 36 additions and 6 deletions

View File

@@ -138,7 +138,7 @@ def validate_template(template_id, personalisation, service, notification_type):
def check_service_email_reply_to_id(service_id, reply_to_id):
if not (reply_to_id is None):
try:
reply_to = dao_get_reply_to_by_id(service_id, reply_to_id)
dao_get_reply_to_by_id(service_id, reply_to_id)
except NoResultFound:
message = 'email_reply_to_id {} does not exist in database for service id {}'\
.format(reply_to_id, service_id)

View File

@@ -3,17 +3,17 @@ from app.notifications.validators import (
check_service_over_daily_message_limit,
validate_and_format_recipient,
validate_template,
)
check_service_email_reply_to_id)
from app.notifications.process_notifications import (
create_content_for_notification,
persist_notification,
send_notification_to_queue,
)
persist_email_reply_to_id_for_notification)
from app.models import (
KEY_TYPE_NORMAL,
PRIORITY,
SMS_TYPE,
)
EMAIL_TYPE)
from app.dao.services_dao import dao_fetch_service_by_id
from app.dao.templates_dao import dao_get_template_by_id_and_service_id
from app.dao.users_dao import get_user_by_id
@@ -63,6 +63,10 @@ def send_one_off_notification(service_id, post_data):
key_type=KEY_TYPE_NORMAL,
created_by_id=post_data['created_by']
)
sender_id = post_data.get('sender_id', None)
if sender_id and template.template_type == EMAIL_TYPE:
check_service_email_reply_to_id(service_id, sender_id)
persist_email_reply_to_id_for_notification(notification.id, sender_id)
queue_name = QueueNames.PRIORITY if template.process_type == PRIORITY else None
send_notification_to_queue(