mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Missed a couple of places where we should push to the queue.
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
from datetime import datetime
|
||||
from flask import (jsonify, request, abort)
|
||||
from flask import (jsonify, request, abort, Blueprint)
|
||||
from sqlalchemy.exc import DataError
|
||||
from sqlalchemy.orm.exc import NoResultFound
|
||||
from app.dao.services_dao import get_model_services
|
||||
from app.aws_sqs import add_notification_to_queue
|
||||
from app.dao.users_dao import (
|
||||
get_model_users,
|
||||
save_model_user,
|
||||
@@ -16,8 +17,7 @@ from app.dao.users_dao import (
|
||||
from app.schemas import (
|
||||
user_schema, users_schema, service_schema, services_schema,
|
||||
request_verify_code_schema, user_schema_load_json)
|
||||
from app import notify_alpha_client
|
||||
from flask import Blueprint
|
||||
from app import (notify_alpha_client, api_user)
|
||||
|
||||
|
||||
user = Blueprint('user', __name__)
|
||||
@@ -137,16 +137,24 @@ def send_user_code(user_id):
|
||||
# notify_alpha_client
|
||||
if verify_code.get('code_type') == 'sms':
|
||||
mobile = user.mobile_number if verify_code.get('to', None) is None else verify_code.get('to')
|
||||
notification = {'to': mobile, 'content': secret_code}
|
||||
add_notification_to_queue(api_user['client'], 'admin', 'sms', notification)
|
||||
notify_alpha_client.send_sms(
|
||||
mobile_number=mobile,
|
||||
message=secret_code)
|
||||
elif verify_code.get('code_type') == 'email':
|
||||
email = user.email_address if verify_code.get('to', None) is None else verify_code.get('to')
|
||||
notification = {
|
||||
'to_address': email,
|
||||
'from_address': 'notify@digital.cabinet-office.gov.uk',
|
||||
'subject': 'Verification code',
|
||||
'body': secret_code}
|
||||
add_notification_to_queue(api_user['client'], 'admin', 'sms', notification)
|
||||
notify_alpha_client.send_email(
|
||||
email,
|
||||
secret_code,
|
||||
'notify@digital.cabinet-office.gov.uk',
|
||||
'Verification code')
|
||||
notification['from_address'],
|
||||
notification['subject'])
|
||||
else:
|
||||
abort(500)
|
||||
return jsonify({}), 204
|
||||
|
||||
Reference in New Issue
Block a user