Граф коммитов

98 Коммитов

Автор SHA1 Сообщение Дата
John Whitlock e68f894a7c Move Twilio Number SID to mock_twilio_client
This allows removing repetative setup from relay number creation tests.
Continue removing lines by removing shorter mock names that are just
used once.
2023-01-23 07:39:39 -06:00
John Whitlock 8230a91162 Add CachedList for cached list access 2023-01-23 07:39:39 -06:00
John Whitlock 5d2e141e42 Skip registration if messaging service is unset
Many existing tests rely on acquiring a relay phone number without
TWILIO_MESSAGING_SERVICE_ID being set. Handle this by skipping
registration and logging a warning.
2023-01-23 07:39:39 -06:00
John Whitlock 709f356dd9 Change TWILIO_MESSAGING_SERVICE_SID to CSV
Change the Twilio messaging service IDs settings to a comma-separated
list. Legacy values will be treated as a list on one entry.

When registeting a US relay phone mask with a messaging service, try
each service in order, stopping after the first successful service. Take
note of full services in the cache to avoid checking them.
2023-01-23 07:39:39 -06:00
John Whitlock a7c8d106ff Test full messaging pool 2023-01-23 07:39:39 -06:00
John Whitlock 5d72ad973d Add real_phone_us fixture
Add fixture that creates a real phone number and resets the Twilio
client mock, to clear the sent confirmation message. Use the fixture in
tests of allocating a US-based relay number. Refactor tests to remove
redundant assertions and test all mocked parameters.
2023-01-23 07:39:39 -06:00
John Whitlock a71465975f Narrow twilio_client mock
Rename to mock_twilio_client, and remove the unnecessary reassignments
in tests. Restrict the mocked interfaces to those used by phones models.
2023-01-23 07:39:39 -06:00
John Whitlock 8d28e9230d flake8 fixes 2023-01-23 07:39:39 -06:00
groovecoder 3ef028e93c update PhonesConfig.twiml_app to assert return type 2022-12-16 09:41:11 -06:00
John Whitlock 2726ac9bf7
Avoid circular import 2022-11-30 17:11:55 -06:00
John Whitlock d71d133c8c
Lint and add types for _handle_sms_reply 2022-11-30 17:11:54 -06:00
John Whitlock cbcf8202a7
Move storing_phone_log to RelayNumber property 2022-11-30 17:11:54 -06:00
John Whitlock 5be00beb2b Use decouple.CSV for comma-separated settings
decouple.CSV will convert a string with a comma-separated value into a
list, and will remove empty strings ("foo," -> ["foo"]).
2022-11-28 14:48:51 -06:00
John Whitlock be3425e379
Track last text and last call times
Add nullable last_call_date and last_text_date to InboundContact. Set
when a call or text is received.

Use last_inbound_contact and last_text_date to find the last texter.
2022-11-16 19:37:18 -06:00
John Whitlock 4b241fb67b Switch Twilio clients to initialize on first use
Instead of initializing Twilio clients on application startup,
initialize them on first use. This benefits applications that
do not use phones, such as ./manage.py migrate. They startup faster, and
do not need Twilio account settings in the environment.
2022-11-09 10:29:47 -06:00
groovecoder 6bfb76d312
fix MPP-2390: sms and voice status callbacks delete data from twilio 2022-10-24 14:34:17 -05:00
groovecoder 24d44089a5 first phones_* stats pings 2022-10-11 16:42:50 -05:00
Se Yeon Kim 8e485f0dae
Use math instead of if statement
to return 0 or positive int for remaining_minutes
2022-10-10 16:59:33 -05:00
Se Yeon Kim 4c53c9f86c
Return non-negative integer when converting remaining seconds to minutes 2022-10-10 16:59:32 -05:00
John Whitlock 6abb5a9437
MPP-2332: Handle dupe US A2P 10DLC registration
Ignore error 21710 when a US relay number is already registered with the
US A2P 10DLC campaign.
2022-10-06 12:37:01 -05:00
John Whitlock d624b1a0d4
Add unique index for RelayNumber.number 2022-10-06 12:37:01 -05:00
John Whitlock 915c6512a2
Test ValidationError messages 2022-10-06 12:37:01 -05:00
John Whitlock 4aa5d476bd
Raise ValidationError for dupe RelayNumber.number 2022-10-06 12:37:01 -05:00
John Whitlock e9f5b57ec5
Enforce one RelayNumber per user 2022-10-06 12:37:01 -05:00
John Whitlock b36235cb5b
Refactor to use pytest.raises
pytest.raises is more explicit than a try/except block, and fails
automatically when the exception is not raised.
2022-10-06 12:37:01 -05:00
John Whitlock f8776e397a Add random numbers to suggested relay numbers 2022-10-06 10:28:05 -05:00
John Whitlock 47a8693902
Fix spelling
Co-authored-by: Se Yeon Kim <25109943+say-yawn@users.noreply.github.com>
2022-10-05 10:35:20 -05:00
John Whitlock 77bd32fc02
Fix postgres migration 2022-10-05 10:35:20 -05:00
John Whitlock 5b824db269
Fix migration against 2022.09.21.01 2022-10-05 10:35:20 -05:00
John Whitlock 7e55e3a037
Use 10-digit patterns for suggestions
This changes the 2-digit prefix/suffix pattern, but seems to be a better
reflection of what was intended.
2022-10-05 10:35:20 -05:00
John Whitlock 1a5f4e534b
Add RelayNumber.country_code to API, mocks
* Expose RelayNumber.country_code as a read-only API attribute.
* When fetching phone suggestions or searching for an area code or
  location, use the RealPhone.country_code.
* Set the RelayNumber.country_code to the RealPhone.country_code,
  assuming it was picked from the suggestions or search.
* Skip US A2P 10DLC registration for non-US numbers
2022-10-05 10:35:20 -05:00
John Whitlock 732e85e03e
Add country_code col to RealPhone and RelayNumber 2022-10-05 10:35:19 -05:00
John Whitlock dec18afb8e
Add default to migration 2022-09-27 15:59:09 -10:00
John Whitlock 008cd3a519
Add relaynumber.remaining_minutes back
The column needs to exist until the next deploy.
2022-09-27 15:47:07 -10:00
groovecoder 967629c1ce move db default function after removing field 2022-09-21 21:08:42 -05:00
groovecoder 8b996c0acb fix MPP-2351: make remaining_minutes a calculated property 2022-09-21 21:08:42 -05:00
groovecoder 0e9324c374 fix MPP-2351: add voice_status callback endpoint
/voice_status receives Twilio call status callback requests and  updates
RelayNumber.remaining_seconds
2022-09-21 21:08:42 -05:00
groovecoder cd52a6d1bb fix MPP-2332: add relay numbers to messaging service 2022-09-21 15:26:56 -05:00
groovecoder aac4cdd642 fix MPP-2349: welcome text message copy 2022-09-21 09:47:40 +02:00
groovecoder e0a4dcbe2a
fix SUBSCRIPTIONS_WITH_PHONE logic 2022-09-19 16:21:43 -05:00
groovecoder 09c6186f78
change RelayNumber stats fields to non-blanks 2022-09-13 15:28:12 -05:00
groovecoder 9de44f4cae
for MPP-2174: add calls_and_texts_blocked|forwarded to API 2022-09-10 17:26:33 -05:00
groovecoder f63e1b1553
for MPP-2174: add minutes, texts, and call stats 2022-09-10 17:26:32 -05:00
groovecoder 9f7478efc3
format all code with black 2022-08-29 16:41:35 -05:00
groovecoder 62910924b5
catch InboundContact.DoesNotExist from latest() 2022-08-29 14:57:47 -05:00
groovecoder 6fdfd97e5d
remove unused logger from phones.models 2022-08-29 13:50:41 -05:00
luke crouch ef08a5a83f
Update phones/models.py
Co-authored-by: John Whitlock <jwhitlock@mozilla.com>
2022-08-29 13:49:40 -05:00
groovecoder b7dc5d6d65
test get_last_text_sender 2022-08-24 15:28:10 -05:00
groovecoder 40ef4b3504
fix MPP-2308: update inbound_sms to handle replies 2022-08-24 14:49:50 -05:00
John Whitlock 6dbee1f4bb
Fix tests with PHONES_ENABLED=false 2022-08-23 14:58:20 -05:00