mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-18 05:28:49 -04:00
make inbound sms honour data retention
code inspired by the delete notification code, but with some clean up since we don't deal with different types etc, and only need to run the query for services with inbound numbers also, update tests.app.db.create_inbound_sms to create inbound numbers and assign them to services to ensure the test db is always accurate and reflects real world usage
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import random
|
||||
import uuid
|
||||
from datetime import datetime, date
|
||||
|
||||
@@ -318,10 +319,18 @@ def create_inbound_sms(
|
||||
provider="mmg",
|
||||
created_at=None
|
||||
):
|
||||
if not service.inbound_number:
|
||||
create_inbound_number(
|
||||
# create random inbound number
|
||||
notify_number or '07{:09}'.format(random.randint(0, 1e9 - 1)),
|
||||
provider=provider,
|
||||
service_id=service.id
|
||||
)
|
||||
|
||||
inbound = InboundSms(
|
||||
service=service,
|
||||
created_at=created_at or datetime.utcnow(),
|
||||
notify_number=notify_number or service.get_default_sms_sender(),
|
||||
notify_number=service.get_inbound_number(),
|
||||
user_number=user_number,
|
||||
provider_date=provider_date or datetime.utcnow(),
|
||||
provider_reference=provider_reference or 'foo',
|
||||
|
||||
Reference in New Issue
Block a user