Add docs/code comments for message-send-flow

This commit is contained in:
Andrew Shumway
2024-03-18 11:45:40 -06:00
parent 0e1c5e4c9d
commit 6599c284cc
5 changed files with 16 additions and 14 deletions

View File

@@ -91,13 +91,13 @@ 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):
''' """
This logic will branch off to the final step in delivering This logic will branch off to the final step in delivering
the notification to sns. the notification to sns.
Logic is in place for delivery receipts. Logic is in place for delivery receipts.
Additional logic to help devs output authentication code to Additional logic to help devs output authentication code to
terminal. 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)

View File

@@ -31,10 +31,10 @@ 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):
''' """
We update job status, get the csv data from s3 and begin processing We update job status, get the csv data from s3 and begin processing
csv rows. 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 +114,10 @@ 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):
''' """
The process will branch off based on notification type, The process will branch off based on notification type,
sms or email. sms or email.
''' """
template_type = template.template_type template_type = template.template_type
encrypted = encryption.encrypt( encrypted = encryption.encrypt(
{ {
@@ -175,10 +175,10 @@ 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):
''' """
We are persisting the notification to the db here and We are persisting the notification to the db here and
placing notification in queue to send to sns. 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

View File

@@ -22,11 +22,11 @@ from app.serialised_models import SerialisedService, SerialisedTemplate
def send_sms_to_provider(notification): def send_sms_to_provider(notification):
''' """
This is the last step in the message send flow. This is the last step in the message send flow.
We get necessary data for recipient, template, We get necessary data for recipient, template,
notification and send it off to the provider. notification and send it off to the provider.
''' """
# 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
# However, we are still sending the initial verify code through personalisation # However, we are still sending the initial verify code through personalisation

View File

@@ -166,10 +166,10 @@ 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 Entry point from UI for one-off messages
as well as CSV uploads. 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)

View File

@@ -469,7 +469,8 @@ def upgrade():
postgresql_using=enum_using("notification_type", NotificationType), postgresql_using=enum_using("notification_type", NotificationType),
) )
# Clobbering bad data here. These are values we don't use any more, and anything with them is unnecessary. # Clobbering bad data here. These are values we don't use any more, and anything with them is unnecessary.
op.execute(""" op.execute(
"""
delete from delete from
service_permissions service_permissions
where where
@@ -480,7 +481,8 @@ def upgrade():
'international_letters', 'international_letters',
'broadcast' 'broadcast'
); );
""") """
)
op.alter_column( op.alter_column(
"service_permissions", "service_permissions",
"permission", "permission",