mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 17:31:14 -05:00
- Implemented persist_notification and send_notification_to_queue in the process_notifications module
- Not sure I want to create a new classmethod on Notifications to create from v2 request. Will take another look at that.
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
from flask import request
|
||||
|
||||
from flask import request, jsonify
|
||||
from app import api_user
|
||||
from app.dao import services_dao, templates_dao
|
||||
from app.models import SMS_TYPE
|
||||
from app.notifications.process_notifications import create_content_for_notification
|
||||
from app.notifications.process_notifications import create_content_for_notification, persist_notification, \
|
||||
send_notification_to_queue
|
||||
from app.notifications.validators import (check_service_message_limit,
|
||||
check_template_is_for_notification_type,
|
||||
check_template_is_active,
|
||||
@@ -11,7 +11,8 @@ from app.notifications.validators import (check_service_message_limit,
|
||||
check_sms_content_char_count)
|
||||
from app.schema_validation import validate
|
||||
from app.v2.notifications import notification_blueprint
|
||||
from app.v2.notifications.notification_schemas import post_sms_request
|
||||
from app.v2.notifications.notification_schemas import (post_sms_request,
|
||||
create_post_sms_response_from_notification)
|
||||
|
||||
|
||||
@notification_blueprint.route('/sms', methods=['POST'])
|
||||
@@ -34,9 +35,17 @@ def post_sms_notification():
|
||||
check_sms_content_char_count(template_with_content.replaced_content_count)
|
||||
|
||||
# persist notification
|
||||
# send sms to provider queue for research mode queue
|
||||
# return post_sms_response schema
|
||||
return "post_sms_response schema", 201
|
||||
notification = persist_notification(template_id=template.id,
|
||||
template_version=template.version,
|
||||
recipient=form['phone_number'],
|
||||
service_id=service.id,
|
||||
personalisation=form.get('personalisation', None),
|
||||
notification_type=SMS_TYPE,
|
||||
api_key_id=api_user.id,
|
||||
key_type=api_user.key_type)
|
||||
send_notification_to_queue(notification, service.research_mode)
|
||||
resp = create_post_sms_response_from_notification(notification, template_with_content.content)
|
||||
return jsonify(resp), 201
|
||||
|
||||
|
||||
@notification_blueprint.route('/email', methods=['POST'])
|
||||
|
||||
Reference in New Issue
Block a user