Commit Graph

164 Commits

Author SHA1 Message Date
Chris Hill-Scott
28f01bd776 Use utils template to format broadcast content
Brings in:
- [x] https://github.com/alphagov/notifications-utils/pull/801

Formats the content of the template at the time of creating the event.
This means that any downstream code (eg Celery tasks) can assume the
content is already formatted correctly.

Also, these downstream tasks don’t  know which template the broadcast
was created from, so if we support personalisation in the future this is
the most sensible place to bring together the template and the
personalisation.

---

I had to re-create some of the deleted code from utils for stuff like
formatting the timestamp to the CAP standard.
2020-10-27 10:55:26 +00:00
Chris Hill-Scott
29ff625a4b Bump utils to 42.2.1
Changes: https://github.com/alphagov/notifications-utils/compare/42.2.0...42.2.1
2020-09-29 12:34:44 +01:00
Chris Hill-Scott
379a227a1d Bump utils to 42.2.0
Increases CSV row limit from 50,000 to 100,000

Changes: https://github.com/alphagov/notifications-utils/compare/42.0.0...42.2.0
2020-09-25 18:16:14 +01:00
David McDonald
5b2dee5ddb Bump utils to 42.0.0
Requires unit test updating as we now expect broadcast event areas to
be a dict containing a list of areas and simple polygons.
2020-09-14 15:21:55 +01:00
David McDonald
288e3ae811 Bring in latest version of utils to fix link breaking bug
Fixes https://github.com/alphagov/notifications-utils/pull/784

Note, also is a breaking change of the utils, see
https://github.com/alphagov/notifications-utils/pull/769
but I don't believe it requires any changes on the API because of this
2020-09-10 14:32:02 +01:00
David McDonald
86565fcee9 make freeze 2020-09-07 14:24:13 +01:00
pyup-bot
87599dce4a Update sqlalchemy from 1.3.18 to 1.3.19 2020-09-02 14:00:06 +01:00
pyup-bot
c5688dde2b Update eventlet from 0.26.1 to 0.27.0 2020-09-02 14:00:05 +01:00
pyup-bot
e7e1e9d478 Update flask-marshmallow from 0.11.0 to 0.13.0 2020-09-02 14:00:04 +01:00
pyup-bot
90045646d3 Update cffi from 1.14.1 to 1.14.2 2020-09-02 14:00:03 +01:00
David McDonald
1b36a75927 Dont upgrade flask marshmallow as breaks things 2020-08-18 12:04:48 +01:00
pyup-bot
8cf92bd8d8 Update gds-metrics from 0.2.2 to 0.2.4 2020-08-18 09:58:36 +01:00
pyup-bot
695aefc014 Update prometheus-client from 0.7.1 to 0.8.0 2020-08-18 09:58:36 +01:00
pyup-bot
8faa8392e6 Update notifications-python-client from 5.5.1 to 5.7.0 2020-08-18 09:58:36 +01:00
pyup-bot
d8b5d99c4b Update cachetools from 4.1.0 to 4.1.1 2020-08-18 09:58:36 +01:00
pyup-bot
70f070e6b5 Update sqlalchemy from 1.3.17 to 1.3.18 2020-08-18 09:58:36 +01:00
pyup-bot
92fb28e6ec Update marshmallow-sqlalchemy from 0.23.0 to 0.23.1 2020-08-18 09:58:36 +01:00
pyup-bot
5dbc6fac3f Update flask-marshmallow from 0.11.0 to 0.13.0 2020-08-18 09:58:36 +01:00
pyup-bot
231fca04ec Update cffi from 1.14.0 to 1.14.1 2020-08-18 09:58:36 +01:00
Leo Hemsted
1c48e2efb2 reqs bump 2020-08-14 10:47:28 +01:00
Katie Smith
baebc5bdaf Bump eventlet
dnspython had been changed from 1.16.0 to 2.0.0 in a previous commit,
but this was not compatible with eventlet 0.25.2. This bumps eventlet to
a later version, which has the effect of downgrading dnspython again.
2020-07-31 10:36:09 +01:00
Katie Smith
4931fc396c Bump utils to 40.6.0
This brings in validation for invalid characters in address lines.
2020-07-31 08:58:56 +01:00
David McDonald
34538bcad8 Fix risk of uncaught exceptions due to gds metrics
Similar to https://github.com/alphagov/notifications-admin/pull/3510

Because of https://github.com/alphagov/gds_metrics_python/pull/8
2020-07-10 10:37:09 +01:00
Leo Hemsted
61a5730596 add more friendly datetime validator to jsonschema
add `datetime` format (note, not the built-in `date-time`) to our json
schemas. this uses the iso8601 library to try and parse the string.

also, move `strict-rfc3339` and `rfc3987` (used by jsonschema to
validate `date-time` and `uri` formats respectively from test
requirements to regular requirements. if they're not installed,
validation silently succeeds, so validation wouldnt reject anything bad
on prod, only in unit tests.
2020-07-09 14:19:58 +01:00
Chris Hill-Scott
e9dfbeca37 Bump utils to 40.2.1
Changes: https://github.com/alphagov/notifications-utils/compare/40.0.0...40.2.1
2020-07-03 14:27:28 +01:00
David McDonald
12f460adc5 Turn off statsd wrapper for synchronous statsd calls during POSTs
This commit turns off StatsD metrics for the following
- the `dao_create_notification` function
- the `user-agent` metric
- the response times and response codes per flask endpoint

This has been done with the purpose of not having the creation of text
messages or emails call out to StatsD during the request process. These
are the three current metrics that are currently called during the
processing of one of those requests and so have been removed from the
API.

The reason for removing the calls out to StatsD when processing a
request to send a notification is that we have seen two incidents
recently affected by DNS resolution for StatsD (either by a slow down in
resolution time or a failure to resolve). These POST requests are our
most critical code path and we don't want them to be affected by any
potential unforeseen trouble with StatsD DNS resolution.

We are not going to miss the removal of these metrics.
- the `dao_create_notification` metric is rarely/never looked at
- the `user-agent` metric is rarely/never looked at and can be got from
  our logs if we want it
- the response times and response codes per flask endpoint are already
  exposed using the gds metrics python library

I did not remove the statsd metrics from any other parts of the API
because
- As the POST notification endpoints are the main source of web traffic,
  we should have already removed most calls to StatsD which should
  greatly reduce the chance of their being any further issues with
  DNS resolution
- Some of the other metrics still provide value so no point deleting
  them if we don't need to
- The metrics on celery tasks will not affect any HTTP requests from
  users as they are async and also we do not currently have the
  infrastructure set up to replace them with a prometheus HTTP endpoint that
  can be scraped so this would require more work
2020-06-29 12:40:22 +01:00
Chris Hill-Scott
3ffdb3093b Revert "Revert "Merge pull request #2887 from alphagov/cache-the-serialised-things""
This reverts commit 7e85e37e1d.
2020-06-26 14:10:12 +01:00
Chris Hill-Scott
7e85e37e1d Revert "Merge pull request #2887 from alphagov/cache-the-serialised-things"
This reverts commit b8c2c6b291, reversing
changes made to 351aca2c5a.
2020-06-26 13:42:44 +01:00
Chris Hill-Scott
6a9818b5fd Cache services and API keys in memory
Same as we’ve done for templates.

For high volume services this should mean avoiding calls to external
services, either the database or Redis.

TTL is set to 2 seconds, so that’s the maximum time it will take for
revoking an API key or renaming a service to propagate.

Some of the tests created services with the same service ID. This
caused intermittent failures because the cache relies on unique service
IDs (like we have in the real world) to key itself.
2020-06-24 08:46:13 +01:00
Pea Tyczynska
7a4f5a4bff Refactor crown dependency check 2020-06-22 18:14:22 +01:00
Pea Tyczynska
ef9f3c1e5f Make sure we check if a service can send to number harmoniously
We were checking this separately in two places in the code. Now
we will have this logic in one place, in validators.

Also pull in utils version that recognises crown depenency numbers
as international.
2020-06-19 15:59:15 +01:00
Leo Hemsted
728e5eee24 re-enable statsd (and cache statsd DNS lookup)
see https://github.com/alphagov/notifications-utils/pull/752 for
implementation details. Cache DNS for 15 seconds. Note: This cache is
per eventlet, so concurrent requests will handle their requests
separately, but the cache does persist between sequential requests.

re-enable statsd for all environments.
2020-06-18 11:20:00 +01:00
Leo Hemsted
faa8faa0c4 bump prometheus-client to 0.7.1
there's multiple performance improvements from prometheus-client 0.2.0.
pin this bump while we wait for gds metrics client to increase its
dependency
2020-06-12 14:52:22 +01:00
Leo Hemsted
bd433ad24f bump utils to fix statsd timing bug
statsd timing should always be in seconds, not milliseconds
2020-06-11 15:01:15 +01:00
Chris Hill-Scott
0f353739f5 Bump utils to 39.4.3
Brings in a bug fix for when a personalisation value is an empty list.
2020-06-09 10:45:09 +01:00
David McDonald
a497f1b945 Bump utils to 39.4.2 to fix whitespace strip bug
https://github.com/alphagov/notifications-utils/pull/742

We had been seeing phone numbers making it through in jobs containing
this no-break space which were then causing errors as we could not
process the job as it thought it was an invalid number. This should
solve the problem and strip that special character.
2020-06-01 11:12:05 +01:00
Chris Hill-Scott
cac24bfc5e Bump utils to 39.4.1 2020-05-26 11:20:15 +01:00
Chris Hill-Scott
14d5db58f4 Bump utils to 39.4.0
Adds delivery estimates for letters posted to Europe or the rest of the
world.
2020-05-26 11:20:14 +01:00
Katie Smith
e770108ec4 Update sqlalchemy from 1.3.13 to 1.3.17 2020-05-22 10:43:29 +01:00
Katie Smith
20e97bf78a Update psycopg2-binary from 2.8.4 to 2.8.5 2020-05-22 10:41:16 +01:00
Katie Smith
ba38a2d5dd Update marshmallow from 2.20.5 to 2.21.0 2020-05-22 10:38:27 +01:00
Katie Smith
8c72dabbe8 Update marshmallow-sqlalchemy from 0.22.3 to 0.23.0 2020-05-22 10:36:21 +01:00
Katie Smith
bd0ba67889 Update eventlet from 0.25.1 to 0.25.2 2020-05-22 10:34:13 +01:00
Katie Smith
eae99f7504 Update flask from 1.1.1 to 1.1.2 2020-05-22 10:31:15 +01:00
Katie Smith
d06c7adb82 Update flask-migrate from 2.5.2 to 2.5.3 2020-05-22 10:29:16 +01:00
Chris Hill-Scott
a8bac328d2 Bump utils to 39.0.1
Fixes a bug with address validation.
2020-05-06 10:23:50 +01:00
Chris Hill-Scott
0c1373eeb5 Bump utils to 39.0.0
`allow_international_letters` is a new, required argument, so the tests
that make some `Row` objects need to provide that.

There are now 8 possible address columns (7 plus postcode) so the tests
need to expect that. But this won’t have any user-facing impact.
2020-05-01 14:37:24 +01:00
Chris Hill-Scott
ba0d330593 Allow countries in last line of addresses
For services that have permission to send international letters we
should not reject letters that are addressed to another country. We
should still reject letters that are badly-addressed.
2020-05-01 14:37:24 +01:00
Chris Hill-Scott
e366ad29ae Bump utils to 38.0.0
Brings in breaking change to how the `RecipientCSV` class should be
instantiated.
2020-05-01 14:37:23 +01:00
David McDonald
44155d4e7c Bring in utils to bump max fragments to 6 for SMS 2020-04-24 16:01:59 +01:00