Alpha client removed from code. Tests fixed but will wait till other notifications jobs are done before creating a pull request.

This commit is contained in:
Nicholas Staples
2016-02-09 11:38:57 +00:00
parent c1b0cef864
commit 2fda7ee59b
6 changed files with 9 additions and 172 deletions

View File

@@ -17,7 +17,8 @@ notifications = Blueprint('notifications', __name__)
@notifications.route('/<notification_id>', methods=['GET'])
def get_notifications(notification_id):
return jsonify(notify_alpha_client.fetch_notification_by_id(notification_id)), 200
# TODO return notification id details
return jsonify({'id': notification_id}), 200
@notifications.route('/sms', methods=['POST'])
@@ -27,14 +28,10 @@ def create_sms_notification():
notification, errors = sms_template_notification_schema.load(resp_json)
if errors:
return jsonify(result="error", message=errors), 400
template_id = notification['template']
# TODO: remove once beta is reading notifications from the queue
message = templates_dao.get_model_templates(template_id).content
add_notification_to_queue(api_user['client'], template_id, 'sms', notification)
# TODO: remove once beta is reading notifications from the queue
return jsonify(notify_alpha_client.send_sms(
mobile_number=notification['to'], message=message)), 200
add_notification_to_queue(api_user['client'], notification['template'], 'sms', notification)
# TODO data to be returned
return jsonify({}), 200
@notifications.route('/email', methods=['POST'])
@@ -43,14 +40,9 @@ def create_email_notification():
notification, errors = email_notification_schema.load(resp_json)
if errors:
return jsonify(result="error", message=errors), 400
# At the moment we haven't hooked up
# template handling for sending email notifications.
add_notification_to_queue(api_user['client'], "admin", 'email', notification)
return jsonify(notify_alpha_client.send_email(
notification['to_address'],
notification['body'],
notification['from_address'],
notification['subject']))
# TODO data to be returned
return jsonify({}), 200
@notifications.route('/sms/service/<service_id>', methods=['POST'])
@@ -74,10 +66,6 @@ def create_sms_for_service(service_id):
message = "Invalid template: id {} for service id: {}".format(template.id, service_id)
return jsonify(result="error", message=message), 400
# Actual client is delivery app, but this is sent on behalf of service
add_notification_to_queue(service_id, template_id, 'sms', notification)
# TODO: remove once beta is reading notifications from the queue
content = template.content
return jsonify(notify_alpha_client.send_sms(
mobile_number=notification['to'], message=content)), 200
# TODO data to be returned
return jsonify({}), 200

View File

@@ -133,15 +133,10 @@ def send_user_code(user_id):
from app.dao.users_dao import create_secret_code
secret_code = create_secret_code()
create_user_code(user, secret_code, verify_code.get('code_type'))
# TODO this will need to fixed up when we stop using
# 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 = {
@@ -150,11 +145,6 @@ def send_user_code(user_id):
'subject': 'Verification code',
'body': secret_code}
add_notification_to_queue(api_user['client'], 'admin', 'email', notification)
notify_alpha_client.send_email(
email,
secret_code,
notification['from_address'],
notification['subject'])
else:
abort(500)
return jsonify({}), 204