def send_notification_to_queue_detached(key_type, notification_type, notification_id, research_mode, queue=None): if research_mode or key_type == KEY_TYPE_TEST: queue = QueueNames.RESEARCH_MODE if notification_type == SMS_TYPE: if not queue: queue = QueueNames.SEND_SMS deliver_task = provider_tasks.deliver_sms if notification_type == EMAIL_TYPE: if not queue: queue = QueueNames.SEND_EMAIL deliver_task = provider_tasks.deliver_email if notification_type == LETTER_TYPE: if not queue: queue = QueueNames.CREATE_LETTERS_PDF deliver_task = get_pdf_for_templated_letter try: deliver_task.apply_async([str(notification_id)], queue=queue) except Exception: dao_delete_notifications_by_id(notification_id) raise current_app.logger.debug("{} {} sent to the {} queue for delivery".format( notification_type, notification_id, queue))
def send_notification_to_queue(notification, research_mode, queue=None): if research_mode or notification.key_type == KEY_TYPE_TEST: queue = QueueNames.RESEARCH_MODE if notification.notification_type == SMS_TYPE: deliver_task = provider_tasks.deliver_sms if notification.sends_with_custom_number(): deliver_task = provider_tasks.deliver_throttled_sms queue = QueueNames.SEND_THROTTLED_SMS if not queue: queue = QueueNames.SEND_SMS if notification.notification_type == EMAIL_TYPE: if not queue: queue = QueueNames.SEND_EMAIL deliver_task = provider_tasks.deliver_email if notification.notification_type == LETTER_TYPE: if not queue: queue = QueueNames.CREATE_LETTERS_PDF deliver_task = create_letters_pdf try: deliver_task.apply_async([str(notification.id)], queue=queue) except Exception: dao_delete_notifications_by_id(notification.id) raise current_app.logger.debug( "{} {} sent to the {} queue for delivery".format(notification.notification_type, notification.id, queue) )