mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-18 21:48:49 -04:00
Working placeholders in subject with upgraded notifications-utils.
Fix test.
This commit is contained in:
@@ -6,7 +6,7 @@ from flask import Flask, _request_ctx_stack
|
||||
from flask.ext.sqlalchemy import SQLAlchemy
|
||||
from flask_marshmallow import Marshmallow
|
||||
from werkzeug.local import LocalProxy
|
||||
from utils import logging
|
||||
from notifications_utils import logging
|
||||
from app.celery.celery import NotifyCelery
|
||||
from app.clients.sms.mmg import MMGClient
|
||||
from app.clients.sms.twilio import TwilioClient
|
||||
|
||||
@@ -6,7 +6,7 @@ from flask import (
|
||||
|
||||
from itsdangerous import SignatureExpired
|
||||
|
||||
from utils.url_safe_token import check_token
|
||||
from notifications_utils.url_safe_token import check_token
|
||||
|
||||
from app.dao.invited_user_dao import get_invited_user_by_id
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@ from app.clients.sms.mmg import MMGClientException
|
||||
from app.dao.services_dao import dao_fetch_service_by_id
|
||||
from app.dao.templates_dao import dao_get_template_by_id
|
||||
|
||||
from utils.template import Template
|
||||
from notifications_utils.template import Template
|
||||
|
||||
from utils.recipients import (
|
||||
from notifications_utils.recipients import (
|
||||
RecipientCSV,
|
||||
validate_and_format_phone_number,
|
||||
allowed_to_send_to
|
||||
@@ -172,7 +172,6 @@ def process_job(job_id):
|
||||
send_email.apply_async((
|
||||
str(job.service_id),
|
||||
str(create_uuid()),
|
||||
template.subject,
|
||||
"{}@{}".format(job.service.email_from, current_app.config['NOTIFY_EMAIL_DOMAIN']),
|
||||
encrypted,
|
||||
datetime.utcnow().strftime(DATETIME_FORMAT)),
|
||||
@@ -257,7 +256,7 @@ def send_sms(service_id, notification_id, encrypted_notification, created_at):
|
||||
|
||||
|
||||
@notify_celery.task(name="send-email")
|
||||
def send_email(service_id, notification_id, subject, from_address, encrypted_notification, created_at):
|
||||
def send_email(service_id, notification_id, from_address, encrypted_notification, created_at):
|
||||
notification = encryption.decrypt(encrypted_notification)
|
||||
client = aws_ses_client
|
||||
service = dao_fetch_service_by_id(service_id)
|
||||
@@ -293,11 +292,10 @@ def send_email(service_id, notification_id, subject, from_address, encrypted_not
|
||||
dao_get_template_by_id(notification['template']).__dict__,
|
||||
values=notification.get('personalisation', {})
|
||||
)
|
||||
|
||||
reference = client.send_email(
|
||||
from_address,
|
||||
notification['to'],
|
||||
subject,
|
||||
template.replaced_subject,
|
||||
body=template.replaced,
|
||||
html_body=template.as_HTML_email,
|
||||
)
|
||||
|
||||
@@ -61,7 +61,7 @@ def update_invited_user(service_id, invited_user_id):
|
||||
|
||||
|
||||
def _create_invitation(invited_user):
|
||||
from utils.url_safe_token import generate_token
|
||||
from notifications_utils.url_safe_token import generate_token
|
||||
token = generate_token(str(invited_user.id), current_app.config['SECRET_KEY'], current_app.config['DANGEROUS_SALT'])
|
||||
# TODO: confirm what we want to do for this - the idea is that we say expires tomorrow at midnight
|
||||
# and give 48 hours as the max_age
|
||||
|
||||
@@ -9,8 +9,8 @@ from flask import (
|
||||
url_for,
|
||||
json
|
||||
)
|
||||
from utils.recipients import allowed_to_send_to, first_column_heading
|
||||
from utils.template import Template
|
||||
from notifications_utils.recipients import allowed_to_send_to, first_column_heading
|
||||
from notifications_utils.template import Template
|
||||
from app.clients.email.aws_ses import get_aws_responses
|
||||
from app import api_user, encryption, create_uuid, DATETIME_FORMAT, DATE_FORMAT
|
||||
from app.authentication.auth import require_admin
|
||||
@@ -348,7 +348,6 @@ def send_notification(notification_type):
|
||||
send_email.apply_async((
|
||||
service_id,
|
||||
notification_id,
|
||||
template.subject,
|
||||
"{}@{}".format(service.email_from, current_app.config['NOTIFY_EMAIL_DOMAIN']),
|
||||
encryption.encrypt(notification),
|
||||
datetime.utcnow().strftime(DATETIME_FORMAT)
|
||||
|
||||
@@ -10,7 +10,7 @@ from marshmallow import (
|
||||
|
||||
from marshmallow_sqlalchemy import field_for
|
||||
|
||||
from utils.recipients import (
|
||||
from notifications_utils.recipients import (
|
||||
validate_email_address,
|
||||
InvalidEmailError,
|
||||
validate_phone_number,
|
||||
|
||||
@@ -229,7 +229,7 @@ def send_user_reset_password():
|
||||
|
||||
|
||||
def _create_reset_password_url(email):
|
||||
from utils.url_safe_token import generate_token
|
||||
from notifications_utils.url_safe_token import generate_token
|
||||
import json
|
||||
data = json.dumps({'email': email, 'created_at': str(datetime.now())})
|
||||
token = generate_token(data, current_app.config['SECRET_KEY'], current_app.config['DANGEROUS_SALT'])
|
||||
@@ -238,7 +238,7 @@ def _create_reset_password_url(email):
|
||||
|
||||
|
||||
def _create_verification_url(user, secret_code):
|
||||
from utils.url_safe_token import generate_token
|
||||
from notifications_utils.url_safe_token import generate_token
|
||||
import json
|
||||
data = json.dumps({'user_id': str(user.id), 'email': user.email_address, 'secret_code': secret_code})
|
||||
token = generate_token(data, current_app.config['SECRET_KEY'], current_app.config['DANGEROUS_SALT'])
|
||||
|
||||
Reference in New Issue
Block a user