mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 15:31:15 -05:00
PEP-257 changes
This commit is contained in:
@@ -91,13 +91,7 @@ def check_sms_delivery_receipt(self, message_id, notification_id, sent_at):
|
|||||||
bind=True, name="deliver_sms", max_retries=48, default_retry_delay=300
|
bind=True, name="deliver_sms", max_retries=48, default_retry_delay=300
|
||||||
)
|
)
|
||||||
def deliver_sms(self, notification_id):
|
def deliver_sms(self, notification_id):
|
||||||
"""
|
"""Branch off to the final step in delivering the notification to sns and get delivery receipts."""
|
||||||
This logic will branch off to the final step in delivering
|
|
||||||
the notification to sns.
|
|
||||||
Logic is in place for delivery receipts.
|
|
||||||
Additional logic to help devs output authentication code to
|
|
||||||
terminal.
|
|
||||||
"""
|
|
||||||
try:
|
try:
|
||||||
current_app.logger.info(
|
current_app.logger.info(
|
||||||
"Start sending SMS for notification id: {}".format(notification_id)
|
"Start sending SMS for notification id: {}".format(notification_id)
|
||||||
|
|||||||
@@ -31,10 +31,7 @@ from app.v2.errors import TotalRequestsError
|
|||||||
|
|
||||||
@notify_celery.task(name="process-job")
|
@notify_celery.task(name="process-job")
|
||||||
def process_job(job_id, sender_id=None):
|
def process_job(job_id, sender_id=None):
|
||||||
"""
|
""" Update job status, get csv data from s3, and begin processing csv rows."""
|
||||||
We update job status, get the csv data from s3 and begin processing
|
|
||||||
csv rows.
|
|
||||||
"""
|
|
||||||
start = datetime.utcnow()
|
start = datetime.utcnow()
|
||||||
job = dao_get_job_by_id(job_id)
|
job = dao_get_job_by_id(job_id)
|
||||||
current_app.logger.info(
|
current_app.logger.info(
|
||||||
@@ -114,10 +111,7 @@ def get_recipient_csv_and_template_and_sender_id(job):
|
|||||||
|
|
||||||
|
|
||||||
def process_row(row, template, job, service, sender_id=None):
|
def process_row(row, template, job, service, sender_id=None):
|
||||||
"""
|
"""Branch off based on notification type, sms or email."""
|
||||||
The process will branch off based on notification type,
|
|
||||||
sms or email.
|
|
||||||
"""
|
|
||||||
template_type = template.template_type
|
template_type = template.template_type
|
||||||
encrypted = encryption.encrypt(
|
encrypted = encryption.encrypt(
|
||||||
{
|
{
|
||||||
@@ -175,10 +169,7 @@ def __total_sending_limits_for_job_exceeded(service, job, job_id):
|
|||||||
|
|
||||||
@notify_celery.task(bind=True, name="save-sms", max_retries=5, default_retry_delay=300)
|
@notify_celery.task(bind=True, name="save-sms", max_retries=5, default_retry_delay=300)
|
||||||
def save_sms(self, service_id, notification_id, encrypted_notification, sender_id=None):
|
def save_sms(self, service_id, notification_id, encrypted_notification, sender_id=None):
|
||||||
"""
|
"""Persist notification to db and place notification in queue to send to sns."""
|
||||||
We are persisting the notification to the db here and
|
|
||||||
placing notification in queue to send to sns.
|
|
||||||
"""
|
|
||||||
notification = encryption.decrypt(encrypted_notification)
|
notification = encryption.decrypt(encrypted_notification)
|
||||||
# SerialisedService and SerialisedTemplate classes are
|
# SerialisedService and SerialisedTemplate classes are
|
||||||
# used here to grab the same service and template from the cache
|
# used here to grab the same service and template from the cache
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ from app.serialised_models import SerialisedService, SerialisedTemplate
|
|||||||
|
|
||||||
|
|
||||||
def send_sms_to_provider(notification):
|
def send_sms_to_provider(notification):
|
||||||
"""
|
"""Final step in the message send flow.
|
||||||
This is the last step in the message send flow.
|
|
||||||
We get necessary data for recipient, template,
|
Get data for recipient, template,
|
||||||
notification and send it off to the provider.
|
notification and send it to sns.
|
||||||
"""
|
"""
|
||||||
# we no longer store the personalisation in the db,
|
# we no longer store the personalisation in the db,
|
||||||
# need to retrieve from s3 before generating content
|
# need to retrieve from s3 before generating content
|
||||||
|
|||||||
@@ -166,10 +166,7 @@ def get_jobs_by_service(service_id):
|
|||||||
|
|
||||||
@job_blueprint.route("", methods=["POST"])
|
@job_blueprint.route("", methods=["POST"])
|
||||||
def create_job(service_id):
|
def create_job(service_id):
|
||||||
"""
|
"""Entry point from UI for one-off messages as well as CSV uploads."""
|
||||||
Entry point from UI for one-off messages
|
|
||||||
as well as CSV uploads.
|
|
||||||
"""
|
|
||||||
service = dao_fetch_service_by_id(service_id)
|
service = dao_fetch_service_by_id(service_id)
|
||||||
if not service.active:
|
if not service.active:
|
||||||
raise InvalidRequest("Create job is not allowed: service is inactive ", 403)
|
raise InvalidRequest("Create job is not allowed: service is inactive ", 403)
|
||||||
|
|||||||
Reference in New Issue
Block a user