mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 07:21:13 -05:00
code review feedback
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import re
|
||||
|
||||
import botocore
|
||||
from boto3 import Session
|
||||
from expiringdict import ExpiringDict
|
||||
@@ -8,7 +10,7 @@ from app.clients import AWS_CLIENT_CONFIG
|
||||
FILE_LOCATION_STRUCTURE = "service-{}-notify/{}.csv"
|
||||
|
||||
|
||||
JOBS = ExpiringDict(max_len=100, max_age_seconds=3600)
|
||||
JOBS = ExpiringDict(max_len=100, max_age_seconds=3600 * 4)
|
||||
|
||||
|
||||
def get_s3_file(bucket_name, file_location, access_key, secret_key, region):
|
||||
@@ -91,11 +93,7 @@ def get_phone_number_from_s3(service_id, job_id, job_row_number):
|
||||
correct_row = correct_row.split(",")
|
||||
|
||||
my_phone = correct_row[phone_index]
|
||||
my_phone = my_phone.replace("(", "")
|
||||
my_phone = my_phone.replace(")", "")
|
||||
my_phone = my_phone.replace("-", "")
|
||||
my_phone = my_phone.replace(" ", "")
|
||||
my_phone = my_phone.replace("+", "")
|
||||
my_phone = re.sub(r"[\+\s\(\)\-\.]*", "", my_phone)
|
||||
return my_phone
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ DELIVERY_RECEIPT_DELAY_IN_SECONDS = 120
|
||||
@notify_celery.task(
|
||||
bind=True,
|
||||
name="check_sms_delivery_receipt",
|
||||
max_retries=12,
|
||||
max_retries=48,
|
||||
default_retry_delay=300,
|
||||
)
|
||||
def check_sms_delivery_receipt(self, message_id, notification_id, sent_at):
|
||||
@@ -92,7 +92,7 @@ def check_sms_delivery_receipt(self, message_id, notification_id, sent_at):
|
||||
|
||||
|
||||
@notify_celery.task(
|
||||
bind=True, name="deliver_sms", max_retries=12, default_retry_delay=300
|
||||
bind=True, name="deliver_sms", max_retries=48, default_retry_delay=300
|
||||
)
|
||||
def deliver_sms(self, notification_id):
|
||||
try:
|
||||
|
||||
@@ -81,7 +81,12 @@ def send_sms_to_provider(notification):
|
||||
if my_phone:
|
||||
my_phone = my_phone.decode("utf-8")
|
||||
if my_phone is None:
|
||||
raise Exception("what happened to the phone number")
|
||||
si = notification.service_id
|
||||
ji = notification.job_id
|
||||
jrn = notification.job_row_number
|
||||
raise Exception(
|
||||
f"The phone number for (Service ID: {si}; Job ID: {ji}; Job Row Number {jrn} was not found."
|
||||
)
|
||||
send_sms_kwargs = {
|
||||
"to": my_phone,
|
||||
"content": str(template),
|
||||
|
||||
Reference in New Issue
Block a user