Commit Graph
597 Commits
Author SHA1 Message Date
Kenneth Kehl cbed8b8104 retry 2023-07-12 14:52:40 -07:00
Kenneth Kehl d7ad65ef89 remove autocommit and clean up some bad debug statements 2023-06-27 13:06:38 -07:00
Kenneth Kehl 48ce584773 merge from main 2023-05-11 07:16:25 -07:00
Ryan Ahearn 663ea8435e Fix SNS cert address regex to allow govcloud region domain 2023-05-09 12:04:05 -04:00
Kenneth Kehl be04edd04a fix some issues uncovered during testing 2023-05-01 13:26:19 -07:00
Kenneth Kehl 9de806000a notify-300 set total message limit of 250k 2023-04-28 12:37:06 -07:00
Steven Reilly 8d87b6ec09 Add a total-message daily limit (#195) 2023-03-14 16:28:38 -04:00
Steven Reilly ff4190a8eb Remove letters-related code (#175)
This deletes a big ol' chunk of code related to letters. It's not everything—there are still a few things that might be tied to sms/email—but it's the the heart of letters function. SMS and email function should be untouched by this.

Areas affected:

- Things obviously about letters
- PDF tasks, used for precompiling letters
- Virus scanning, used for those PDFs
- FTP, used to send letters to the printer
- Postage stuff
2023-03-02 20:20:31 -05:00
Ryan Ahearn d1c03e5e8c Get SES config from VCAP_SERVICES 2023-01-31 17:27:17 -05:00
Ryan Ahearn bfeb65c914 Install newrelic and enable in development 2023-01-18 09:06:09 -05:00
Ryan Ahearn 828671ecfc Remove obsolete strip_leading_plus_one method 2023-01-06 11:14:45 -05:00
Ryan Ahearn abc7b09d0d Update app to utilize updated phone validation methods 2023-01-05 11:06:12 -05:00
Ryan Ahearn 7878316790 Remove placeholder sms callback comments 2023-01-03 10:23:14 -05:00
Ryan Ahearn 44a4b2d1a9 Remove firetext from notifications_sms_callback.py 2022-12-22 10:01:12 -05:00
Ryan Ahearn 6a04be0370 Remove firetext and mmg from inbound SMS options 2022-12-22 09:31:12 -05:00
stvnrlly 8e2b8dd7c4 keep on flakin the flake world 2022-10-21 13:29:52 +00:00
stvnrlly 9f37592b1e cleaner flake8 cleaning 2022-10-21 00:26:37 +00:00
stvnrlly e9fdfd59f4 clean flake8 except provider code 2022-10-19 16:16:26 +00:00
jimmoffet 863dfe39ba config flag for turning off inbound SMS replies 2022-10-07 17:25:31 -07:00
jimmoffet 1230579f83 sns_cert_validator caching 2022-10-04 18:03:38 -07:00
jimmoffet 4feaa06f5d fix migrations 2022-10-04 17:42:04 -07:00
jimmoffet 434b7b2d08 clean up and remove redundancy 2022-10-04 16:01:30 -07:00
jimmoffet fc9e4107c1 all tests passing 2022-10-03 20:07:42 -07:00
jimmoffet c04d1df6b3 fixing tests 2022-10-03 17:16:59 -07:00
jimmoffet 8cb6f60f04 modify inbound notif processing 2022-10-03 09:05:34 -07:00
jimmoffet a03de0dd56 remove outdated validatesns library and replace with maintainable code 2022-09-20 20:11:09 -07:00
jimmoffet f1aec54665 clean up comments and method dupes 2022-09-15 15:48:37 -07:00
jimmoffet b0f819dbd9 canada UK ses callbacks monster mash 2022-09-15 14:59:13 -07:00
Jim Moffet ac8d8d3c29 clean up config 2022-06-25 18:36:39 -07:00
Jim Moffet aa4ec532a4 implement SNS 2022-06-17 11:16:23 -07:00
Katie Smith 8ae2b0bb31 Replace how .dump is called
As with `.load`, only data is now returned instead of a tuple.
2022-05-25 11:35:44 +01:00
Katie Smith bd4f74b359 Replace how .load is called
https://marshmallow.readthedocs.io/en/stable/upgrading.html#schemas-are-always-strict

`.load` doesn't return a `(data, errors)` tuple any more - only data is
returned. A `ValidationError` is raised if validation fails. The code
now relies on the `marshmallow_validation_error` error handler to handle
errors instead of having to raise an `InvalidRequest`. This has no
effect on the response that is returned (a test has been modified to
check).

Also added a new `password` field to the `UserSchema` so that we don't
have to specially check for password errors in the `.create_user` endpoint
- we can let marshmallow handle them.
2022-05-25 11:35:44 +01:00
Ben Thorner c27107fa74 Remove support for Reach provider
This provider was never active and support was never completed, so
there's little value in keeping all this potentially confusing code.
2022-04-29 12:28:08 +01:00
Katie Smith b440f3f904 Use Draft-07 and Draft7Validator everywhere
We were using the Draft4Validator in one place, so this updates it to
the Draft7Validator instead.

The schemas were mostly using draft 4 of the JSON schema, though there
were a couple of schemas that were already of version 7. This updates
them all to version 7, which is the latest version fully supported by
the jsonschema Python package. There are some breaking changes in the
newer version of the schema, but I could not see anywhere would these
affect us. Some of these schemas were not valid in version 4, but are
now valid in version 7 because `"required": []` was not valid in earlier
versions.
2022-04-14 14:46:10 +01:00
Ben Thorner b439fd0718 Add boilerplate for Reach SMS callbacks
This is enough to update a notification in DB:

1. First create a notification in the UI and sent it.

2. Then reset its attributes to pretend it's for Reach.

    update notifications set
      sent_at = null,
      sent_by = null,
      notification_status='sending'
    where id='some-uuid';

3. Change "notification_id" to "<some-uuid>" in the code.

4. Call the boilerplate endpoint for Reach callbacks.

    curl -X POST localhost:6011/notifications/sms/reach

Interestingly there's no foreign key constraint on "sent_by" in the
DB, so this just works: the notification is updated.
2022-03-24 16:56:33 +00:00
Ben Thorner 0b6f1d818b Remove redundant debug logs for providers
We don't log at this level and can always add them in manually if
we need to debug something locally.
2022-03-24 16:47:27 +00:00
Ben Thorner 3d30965193 Downgrade log about orphaned inbound SMS
We can't control who might be sending messages on inbound numbers
that we own i.e. this log isn't an actionable error. Looks like it
used to represent something that _was_ an error [1], but that's not
the case anymore, so it seems reasonable to downgrade it.

[1]: https://github.com/alphagov/notifications-api/commit/d99ab329eb5937c87c50ac51332beadcd26b53f5#diff-80d123d9abb40f80a221979940657a2751cc7cb33f255aa8f352a8324023e022L125
2021-12-21 12:49:00 +00:00
Ben Thorner 04da017558 DRY-up conditionally creating callback tasks
This removes 3 duplicate instances of the same code, which is still
tested implicitly via test_process_ses_receipt_tasks [1]. In the
next commit we'll make this test more explicit, to reflect that it's
now being reused elsewhere and shouldn't change arbitrarily.

We do lose the "print" statement from the command instance of the
code, but I think that's a very tolerable loss.

[1]: https://github.com/alphagov/notifications-api/blob/16ec8ccb8a6e4284eef7ec27c389419b761f39f0/tests/app/celery/test_process_ses_receipts_tasks.py#L94
2021-12-06 14:11:34 +00:00
Rebecca Law c501c92bf3 Convert value from redis to an int.
This has been properly tested locally with redis enabled.
2021-06-29 14:00:25 +01:00
Rebecca Law ed788cb0bd Fix bug in check_service_over_daily_limit
I forgot to return service_stats if the cache exists. And fixed the tests to check service_stats value.
2021-06-29 12:59:20 +01:00
Rebecca Law fd7486d751 - Merge daily limit functions into one, refactor call for daily limit check from process_job
- refactor tests to standardise test names
- refactor some tests to be more clear
- remove unnecessary tests
- include missing test
2021-06-24 11:05:22 +01:00
Rebecca Law 57fb9da414 - change the condition so that we don't reset the cache if it's zero
- set the cache if it doesn't exist so there is an expiry of 24 hours.
2021-06-23 15:09:09 +01:00
Rebecca Law 35b20ba363 Correct the daily limits cache.
Last year we had an issue with the daily limit cache and the query that was populating it. As a result we have not been checking the daily limit properly. This PR should correct all that.

The daily limit cache is not being incremented in app.notifications.process_notifications.persist_notification, this method is and should always be the only method used to create a notification.
We increment the daily limit cache is redis is enabled (and it is always enabled for production) and the key type for the notification is team or normal.

We check if the daily limit is exceed in many places:
 - app.celery.tasks.process_job
 -  app.v2.notifications.post_notifications.post_notification
 - app.v2.notifications.post_notifications.post_precompiled_letter_notification
 - app.service.send_notification.send_one_off_notification
 - app.service.send_notification.send_pdf_letter_notification

If the daily limits cache is not found, set the cache to 0 with an expiry of 24 hours. The daily limit cache key is service_id-yyy-mm-dd-count, so each day a new cache is created.

The best thing about this PR is that the app.service_dao.fetch_todays_total_message_count query has been removed. This query was not performant and had been wrong for ages.
2021-06-22 16:15:36 +01:00
David McDonald 04e23ca6a9 Revert "Bump utils version for new invalid address character" 2021-06-01 10:53:28 +01:00
Rebecca Law bd1498f49f Bump utils version which contains ~ as an invalid first character for a
postal address.
2021-05-25 08:29:25 +01:00
Ben Thorner 86b6217cf3 Log service ID for invalid inbound SMS
This could help identify issues with inbound SMS for a service.
2021-03-31 10:22:34 +01:00
Pea Tyczynska 52c529ab3a Use personalisation to set client_reference for letters
which were sent through Notify interface only. This is done
to avoid performance dip from additional operation for
other notification types.
2021-03-24 14:55:10 +00:00
Pea Tyczynska a2da8bc070 If client reference not given, try to get it from personalisation.
This is mostly useful for letters.

For templated letters sent via interface, whether one-offs
or CSV uploads, we do not give our users a way to set client reference.

Still, they often have a placeholder with reference that we could use
to set client_reference field.

Why is this helpful?

When letter is returned, or when we experience some printing issues,
often it is difficult to identify letters after the retention period.

This change will make it easier for some users to identify letters.
It will have more impact if we inform our users of this in template
editing guidance.
2021-03-24 14:55:10 +00:00
Ben Thorner a91fde2fda Run auto-correct on app/ and tests/ 2021-03-12 11:45:45 +00:00
Rebecca Law 87cf3afdc9 Update notifications-utils version.
Postal address validation now includes `< >` in the invalid characters allowed at the start of an address line.
2021-02-10 10:26:00 +00:00