Add simulated SMS numbers to allow list in trial mode

This commit is contained in:
Andrew Shumway
2024-03-13 16:31:21 -06:00
parent e9148851fb
commit 599652256e
2 changed files with 24 additions and 13 deletions

View File

@@ -1,4 +1,3 @@
import itertools
import time
import uuid
from string import ascii_uppercase
@@ -517,19 +516,27 @@ def _check_messages(service_id, template_id, upload_id, preview_row):
current_service,
show_recipient=False,
)
allow_list = []
if current_service.trial_mode:
# Adding the simulated numbers to allow list
# so they can be sent in trial mode
for user in Users(service_id):
allow_list.extend([user.name, user.mobile_number, user.email_address])
# Failed sms number
allow_list.extend(["simulated user", "+14254147167", "simulated@simulated.gov"])
# Success sms number
allow_list.extend(
["simulated user two", "+14254147755", "simulatedtwo@simulated.gov"]
)
else:
allow_list = None
recipients = RecipientCSV(
contents,
template=template or simplifed_template,
max_initial_rows_shown=50,
max_errors_shown=50,
guestlist=(
itertools.chain.from_iterable(
[user.name, user.mobile_number, user.email_address]
for user in Users(service_id)
)
if current_service.trial_mode
else None
),
guestlist=allow_list,
remaining_messages=remaining_messages,
allow_international_sms=current_service.has_permission("international_sms"),
)
@@ -560,7 +567,9 @@ def _check_messages(service_id, template_id, upload_id, preview_row):
if preview_row < len(recipients) + 2:
template.values = recipients[preview_row - 2].recipient_and_personalisation
simplifed_template.values = recipients[preview_row - 2].recipient_and_personalisation
simplifed_template.values = recipients[
preview_row - 2
].recipient_and_personalisation
elif preview_row > 2:
abort(404)
@@ -863,7 +872,7 @@ def _check_notification(service_id, template_id, exception=None):
back_link_from_preview=back_link_from_preview,
choose_time_form=choose_time_form,
**(get_template_error_dict(exception) if exception else {}),
simplifed_template=simplifed_template
simplifed_template=simplifed_template,
)