mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 15:46:07 -05:00
Add sms sender to service to be used in sms templates
in place of default numeric short code. If not present default short code is used.
This commit is contained in:
@@ -1,27 +1,24 @@
|
||||
import json
|
||||
|
||||
from datetime import datetime
|
||||
from monotonic import monotonic
|
||||
from flask import current_app
|
||||
from app import notify_celery, statsd_client, encryption, clients
|
||||
from app import notify_celery, statsd_client, clients
|
||||
from app.clients.sms import SmsClientException
|
||||
|
||||
from app.dao.notifications_dao import (
|
||||
update_provider_stats,
|
||||
get_notification_by_id,
|
||||
dao_update_notification, update_notification_status_by_id)
|
||||
dao_update_notification,
|
||||
update_notification_status_by_id
|
||||
)
|
||||
|
||||
from app.dao.provider_details_dao import get_provider_details_by_notification_type
|
||||
from app.dao.services_dao import dao_fetch_service_by_id
|
||||
from app.dao.templates_dao import dao_get_template_by_id
|
||||
|
||||
from app.celery.research_mode_tasks import send_sms_response
|
||||
|
||||
from notifications_utils.recipients import (
|
||||
validate_and_format_phone_number
|
||||
)
|
||||
|
||||
from app.dao.templates_dao import dao_get_template_by_id
|
||||
from notifications_utils.template import (
|
||||
Template,
|
||||
unlink_govuk_escaped
|
||||
)
|
||||
from notifications_utils.recipients import validate_and_format_phone_number
|
||||
from notifications_utils.template import Template
|
||||
|
||||
from app.models import SMS_TYPE
|
||||
|
||||
@@ -57,12 +54,12 @@ def send_sms_to_provider(self, service_id, notification_id, encrypted_notificati
|
||||
provider = provider_to_use(SMS_TYPE, notification_id)
|
||||
notification = get_notification_by_id(notification_id)
|
||||
if notification.status == 'created':
|
||||
template_model = dao_get_template_by_id(notification.template_id, notification.template_version)
|
||||
template = Template(
|
||||
dao_get_template_by_id(notification.template_id, notification.template_version).__dict__,
|
||||
template_model.__dict__,
|
||||
values={} if not notification.personalisation else notification.personalisation,
|
||||
prefix=service.name
|
||||
)
|
||||
|
||||
try:
|
||||
if service.research_mode:
|
||||
send_sms_response.apply_async(
|
||||
@@ -72,7 +69,8 @@ def send_sms_to_provider(self, service_id, notification_id, encrypted_notificati
|
||||
provider.send_sms(
|
||||
to=validate_and_format_phone_number(notification.to),
|
||||
content=template.replaced,
|
||||
reference=str(notification_id)
|
||||
reference=str(notification_id),
|
||||
sender=service.sms_sender
|
||||
)
|
||||
|
||||
update_provider_stats(
|
||||
|
||||
Reference in New Issue
Block a user