diff --git a/app/job/rest.py b/app/job/rest.py index 00b55e4cde..6f4b567f40 100644 --- a/app/job/rest.py +++ b/app/job/rest.py @@ -169,31 +169,32 @@ def create_job(service_id): placeholders=template._as_utils_template().placeholders, template=Template(template.__dict__), ) + notification_count = int(data.get("notification_count", len(recipient_csv))) current_app.logger.info(" TEMP LOGGING 5: done RecipientCSV()") if template.template_type == SMS_TYPE: # calculate the number of simulated recipients numberOfSimulated = sum(simulated_recipient(i["phone_number"].data, template.template_type) for i in recipient_csv.rows) - mixedRecipients = numberOfSimulated > 0 and numberOfSimulated != len(recipient_csv) + mixedRecipients = numberOfSimulated > 0 and numberOfSimulated != notification_count # if they have specified testing and NON-testing recipients, raise an error if mixedRecipients: raise InvalidRequest(message="Bulk sending to testing and non-testing numbers is not supported", status_code=400) - is_test_notification = len(recipient_csv) == numberOfSimulated + is_test_notification = notification_count == numberOfSimulated if not is_test_notification: - check_sms_daily_limit(service, len(recipient_csv)) - increment_sms_daily_count_send_warnings_if_needed(service, len(recipient_csv)) + check_sms_daily_limit(service, notification_count) + increment_sms_daily_count_send_warnings_if_needed(service, notification_count) elif template.template_type == EMAIL_TYPE: - check_email_daily_limit(service, len(recipient_csv)) + check_email_daily_limit(service, notification_count) current_app.logger.info(" TEMP LOGGING 6a: done check_email_daily_limit") scheduled_for = datetime.fromisoformat(data.get("scheduled_for")) if data.get("scheduled_for") else None if scheduled_for is None or not scheduled_for.date() > datetime.today().date(): - increment_email_daily_count_send_warnings_if_needed(service, len(recipient_csv)) + increment_email_daily_count_send_warnings_if_needed(service, notification_count) current_app.logger.info(" TEMP LOGGING 6: done checking limits") data.update({"template_version": template.version})