mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-24 01:11:38 -05:00
Added an optional parameter in the form for POST /v2/notifications/sms and /service/<service_id>/send-notification to pass in the SMS sender id.
The send_sms_to_provider still needs to use the SMS sender being passed in to the POST. As part of https://www.pivotaltracker.com/story/show/152106587
This commit is contained in:
@@ -20,8 +20,8 @@ from app.notifications.process_notifications import (
|
||||
persist_notification,
|
||||
persist_scheduled_notification,
|
||||
send_notification_to_queue,
|
||||
simulated_recipient
|
||||
)
|
||||
simulated_recipient,
|
||||
persist_sms_sender_id_for_notification)
|
||||
from app.notifications.process_letter_notifications import (
|
||||
create_letter_notification
|
||||
)
|
||||
@@ -31,7 +31,8 @@ from app.notifications.validators import (
|
||||
check_service_can_schedule_notification,
|
||||
check_service_has_permission,
|
||||
validate_template,
|
||||
check_service_email_reply_to_id
|
||||
check_service_email_reply_to_id,
|
||||
check_service_sms_sender_id
|
||||
)
|
||||
from app.schema_validation import validate
|
||||
from app.v2.errors import BadRequestError
|
||||
@@ -63,12 +64,14 @@ def post_notification(notification_type):
|
||||
|
||||
scheduled_for = form.get("scheduled_for", None)
|
||||
service_email_reply_to_id = form.get("email_reply_to_id", None)
|
||||
service_sms_sender_id = form.get("sms_sender_id", None)
|
||||
|
||||
check_service_can_schedule_notification(authenticated_service.permissions, scheduled_for)
|
||||
|
||||
check_rate_limiting(authenticated_service, api_user)
|
||||
|
||||
check_service_email_reply_to_id(str(authenticated_service.id), service_email_reply_to_id)
|
||||
check_service_email_reply_to_id(str(authenticated_service.id), service_email_reply_to_id, notification_type)
|
||||
check_service_sms_sender_id(str(authenticated_service.id), service_sms_sender_id, notification_type)
|
||||
|
||||
template, template_with_content = validate_template(
|
||||
form['template_id'],
|
||||
@@ -142,9 +145,7 @@ def process_sms_or_email_notification(*, form, notification_type, api_key, templ
|
||||
simulated=simulated
|
||||
)
|
||||
|
||||
email_reply_to_id = form.get("email_reply_to_id", None)
|
||||
if email_reply_to_id:
|
||||
persist_email_reply_to_id_for_notification(notification.id, email_reply_to_id)
|
||||
persist_sender_to_notification_mapping(form, notification)
|
||||
|
||||
scheduled_for = form.get("scheduled_for", None)
|
||||
if scheduled_for:
|
||||
@@ -163,6 +164,15 @@ def process_sms_or_email_notification(*, form, notification_type, api_key, templ
|
||||
return notification
|
||||
|
||||
|
||||
def persist_sender_to_notification_mapping(form, notification):
|
||||
email_reply_to_id = form.get("email_reply_to_id", None)
|
||||
if email_reply_to_id:
|
||||
persist_email_reply_to_id_for_notification(notification.id, email_reply_to_id)
|
||||
sms_sender_id = form.get("sms_sender_id", None)
|
||||
if sms_sender_id:
|
||||
persist_sms_sender_id_for_notification(notification.id, sms_sender_id)
|
||||
|
||||
|
||||
def process_letter_notification(*, letter_data, api_key, template):
|
||||
if api_key.key_type == KEY_TYPE_TEAM:
|
||||
raise BadRequestError(message='Cannot send letters with a team api key', status_code=403)
|
||||
|
||||
Reference in New Issue
Block a user