Skip to content

Commit

Permalink
Refactoring: granular params
Browse files Browse the repository at this point in the history
  • Loading branch information
jimleroyer committed Oct 26, 2023
1 parent 2dc05b8 commit 77dd00f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/notifications/process_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,11 @@ def db_save_and_send_notification(notification: Notification):

deliver_task = choose_deliver_task(notification)
try:
deliver_task.apply_async([str(notification.id)], queue=notification.queue_name, **build_delivery_task_params(notification))
deliver_task.apply_async(
[str(notification.id)],
queue=notification.queue_name,
**build_delivery_task_params(notification.notification_type, notification.template.process_type),
)
except Exception:
dao_delete_notifications_by_id(notification.id)
raise
Expand All @@ -220,7 +224,7 @@ def db_save_and_send_notification(notification: Notification):
)


def build_delivery_task_params(notification: Notification):
def build_delivery_task_params(notification_type: str, notification_process_type: str):
"""
Build task params for the sending parameter tasks.
Expand All @@ -231,8 +235,8 @@ def build_delivery_task_params(notification: Notification):
params["retry"] = True
# Overring the retry policy is only supported for SMS for now;
# email support coming later.
if notification.notification_type == SMS_TYPE:
params["retry_policy"] = RETRY_POLICIES[notification.template.process_type]
if notification_type == SMS_TYPE:
params["retry_policy"] = RETRY_POLICIES[notification_process_type]
else:
params["retry_policy"] = RETRY_POLICY_DEFAULT
return params
Expand Down

0 comments on commit 77dd00f

Please sign in to comment.