mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-18 03:11:46 -05:00
Remove unused tasks
Deleted three Celery tasks (send-email, send-sms and persist-letter).
These are not being used anymore - we replaced them in commit
0c9a4bce59.
This commit is contained in:
@@ -180,53 +180,6 @@ def __sending_limits_for_job_exceeded(service, job, job_id):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
@notify_celery.task(bind=True, name="send-sms", max_retries=5, default_retry_delay=300)
|
|
||||||
@statsd(namespace="tasks")
|
|
||||||
def send_sms(self,
|
|
||||||
service_id,
|
|
||||||
notification_id,
|
|
||||||
encrypted_notification,
|
|
||||||
created_at,
|
|
||||||
api_key_id=None,
|
|
||||||
key_type=KEY_TYPE_NORMAL):
|
|
||||||
notification = encryption.decrypt(encrypted_notification)
|
|
||||||
service = dao_fetch_service_by_id(service_id)
|
|
||||||
|
|
||||||
if not service_allowed_to_send_to(notification['to'], service, key_type):
|
|
||||||
current_app.logger.info(
|
|
||||||
"SMS {} failed as restricted service".format(notification_id)
|
|
||||||
)
|
|
||||||
return
|
|
||||||
|
|
||||||
try:
|
|
||||||
saved_notification = persist_notification(
|
|
||||||
template_id=notification['template'],
|
|
||||||
template_version=notification['template_version'],
|
|
||||||
recipient=notification['to'],
|
|
||||||
service=service,
|
|
||||||
personalisation=notification.get('personalisation'),
|
|
||||||
notification_type=SMS_TYPE,
|
|
||||||
api_key_id=api_key_id,
|
|
||||||
key_type=key_type,
|
|
||||||
created_at=datetime.utcnow(),
|
|
||||||
job_id=notification.get('job', None),
|
|
||||||
job_row_number=notification.get('row_number', None),
|
|
||||||
notification_id=notification_id
|
|
||||||
)
|
|
||||||
|
|
||||||
provider_tasks.deliver_sms.apply_async(
|
|
||||||
[str(saved_notification.id)],
|
|
||||||
queue=QueueNames.SEND_SMS if not service.research_mode else QueueNames.RESEARCH_MODE
|
|
||||||
)
|
|
||||||
|
|
||||||
current_app.logger.info(
|
|
||||||
"SMS {} created at {} for job {}".format(saved_notification.id, created_at, notification.get('job', None))
|
|
||||||
)
|
|
||||||
|
|
||||||
except SQLAlchemyError as e:
|
|
||||||
handle_exception(self, notification, notification_id, e)
|
|
||||||
|
|
||||||
|
|
||||||
@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)
|
||||||
@statsd(namespace="tasks")
|
@statsd(namespace="tasks")
|
||||||
def save_sms(self,
|
def save_sms(self,
|
||||||
@@ -276,48 +229,6 @@ def save_sms(self,
|
|||||||
handle_exception(self, notification, notification_id, e)
|
handle_exception(self, notification, notification_id, e)
|
||||||
|
|
||||||
|
|
||||||
@notify_celery.task(bind=True, name="send-email", max_retries=5, default_retry_delay=300)
|
|
||||||
@statsd(namespace="tasks")
|
|
||||||
def send_email(self,
|
|
||||||
service_id,
|
|
||||||
notification_id,
|
|
||||||
encrypted_notification,
|
|
||||||
created_at,
|
|
||||||
api_key_id=None,
|
|
||||||
key_type=KEY_TYPE_NORMAL):
|
|
||||||
notification = encryption.decrypt(encrypted_notification)
|
|
||||||
service = dao_fetch_service_by_id(service_id)
|
|
||||||
|
|
||||||
if not service_allowed_to_send_to(notification['to'], service, key_type):
|
|
||||||
current_app.logger.info("Email {} failed as restricted service".format(notification_id))
|
|
||||||
return
|
|
||||||
|
|
||||||
try:
|
|
||||||
saved_notification = persist_notification(
|
|
||||||
template_id=notification['template'],
|
|
||||||
template_version=notification['template_version'],
|
|
||||||
recipient=notification['to'],
|
|
||||||
service=service,
|
|
||||||
personalisation=notification.get('personalisation'),
|
|
||||||
notification_type=EMAIL_TYPE,
|
|
||||||
api_key_id=api_key_id,
|
|
||||||
key_type=key_type,
|
|
||||||
created_at=datetime.utcnow(),
|
|
||||||
job_id=notification.get('job', None),
|
|
||||||
job_row_number=notification.get('row_number', None),
|
|
||||||
notification_id=notification_id
|
|
||||||
)
|
|
||||||
|
|
||||||
provider_tasks.deliver_email.apply_async(
|
|
||||||
[str(saved_notification.id)],
|
|
||||||
queue=QueueNames.SEND_EMAIL if not service.research_mode else QueueNames.RESEARCH_MODE
|
|
||||||
)
|
|
||||||
|
|
||||||
current_app.logger.info("Email {} created at {}".format(saved_notification.id, created_at))
|
|
||||||
except SQLAlchemyError as e:
|
|
||||||
handle_exception(self, notification, notification_id, e)
|
|
||||||
|
|
||||||
|
|
||||||
@notify_celery.task(bind=True, name="save-email", max_retries=5, default_retry_delay=300)
|
@notify_celery.task(bind=True, name="save-email", max_retries=5, default_retry_delay=300)
|
||||||
@statsd(namespace="tasks")
|
@statsd(namespace="tasks")
|
||||||
def save_email(self,
|
def save_email(self,
|
||||||
@@ -359,43 +270,6 @@ def save_email(self,
|
|||||||
handle_exception(self, notification, notification_id, e)
|
handle_exception(self, notification, notification_id, e)
|
||||||
|
|
||||||
|
|
||||||
@notify_celery.task(bind=True, name="persist-letter", max_retries=5, default_retry_delay=300)
|
|
||||||
@statsd(namespace="tasks")
|
|
||||||
def persist_letter(
|
|
||||||
self,
|
|
||||||
service_id,
|
|
||||||
notification_id,
|
|
||||||
encrypted_notification,
|
|
||||||
created_at
|
|
||||||
):
|
|
||||||
notification = encryption.decrypt(encrypted_notification)
|
|
||||||
|
|
||||||
# we store the recipient as just the first item of the person's address
|
|
||||||
recipient = notification['personalisation']['addressline1']
|
|
||||||
|
|
||||||
service = dao_fetch_service_by_id(service_id)
|
|
||||||
try:
|
|
||||||
saved_notification = persist_notification(
|
|
||||||
template_id=notification['template'],
|
|
||||||
template_version=notification['template_version'],
|
|
||||||
recipient=recipient,
|
|
||||||
service=service,
|
|
||||||
personalisation=notification['personalisation'],
|
|
||||||
notification_type=LETTER_TYPE,
|
|
||||||
api_key_id=None,
|
|
||||||
key_type=KEY_TYPE_NORMAL,
|
|
||||||
created_at=datetime.utcnow(),
|
|
||||||
job_id=notification['job'],
|
|
||||||
job_row_number=notification['row_number'],
|
|
||||||
notification_id=notification_id,
|
|
||||||
reference=create_random_identifier()
|
|
||||||
)
|
|
||||||
|
|
||||||
current_app.logger.info("Letter {} created at {}".format(saved_notification.id, created_at))
|
|
||||||
except SQLAlchemyError as e:
|
|
||||||
handle_exception(self, notification, notification_id, e)
|
|
||||||
|
|
||||||
|
|
||||||
@notify_celery.task(bind=True, name="save-letter", max_retries=5, default_retry_delay=300)
|
@notify_celery.task(bind=True, name="save-letter", max_retries=5, default_retry_delay=300)
|
||||||
@statsd(namespace="tasks")
|
@statsd(namespace="tasks")
|
||||||
def save_letter(
|
def save_letter(
|
||||||
|
|||||||
Reference in New Issue
Block a user