Commit Graph

8209 Commits

Author SHA1 Message Date
Katie Smith
32fa8ee418 Merge pull request #3237 from alphagov/null-to-all
Make service_broadcast_settings.provider non-nullable
2021-05-11 13:35:26 +01:00
Richard Baker
41f324451b Merge pull request #3238 from alphagov/revert-dependabot/pip/eventlet-0.31.0
Revert "Bump eventlet from 0.30.2 to 0.31.0"
2021-05-11 11:12:44 +01:00
Richard Baker
2e34f7b18e Force pyup to ignore eventlet
Signed-off-by: Richard Baker <richard.baker@digital.cabinet-office.gov.uk>
2021-05-11 10:12:01 +01:00
Richard Baker
9acf0f839c Freeze dependencies
Signed-off-by: Richard Baker <richard.baker@digital.cabinet-office.gov.uk>
2021-05-10 18:05:37 +01:00
Richard Baker
ab7c8b3946 Revert "Bump eventlet from 0.30.2 to 0.31.0"
Signed-off-by: Richard Baker <richard.baker@digital.cabinet-office.gov.uk>
2021-05-10 17:42:44 +01:00
Richard Baker
e8a898d269 Merge pull request #3236 from alphagov/ensure-correct-encoding-of-broadcast-events
Normalise content for non-templated broadcast events
2021-05-10 16:45:40 +01:00
Katie Smith
c4d855a1a0 Remove references to broadcast provider_restriction being None
None is not a value that is allowed any more.
2021-05-10 15:59:22 +01:00
Katie Smith
4624328c36 Make service_broadcast_settings.provider non-nullable
We set all existing null values to "all", then make the column
non-nullable. Admin is already passing through the value of "all".
2021-05-10 15:59:22 +01:00
Chris Hill-Scott
0a3be6a662 Normalise content for non-templated broadcast events
We found that non-templated broadcast messages weren’t having their
content normalised before saving into an event.

This means that stuff like `\r\n` and curly quotes were being passed
through to the CBC proxy.

This commit firstly changes templated events to use
`str(BroadcastMessageTemplate)` to normalise the content, because it’s
non-obvious that calling
`BroadcastMessageTemplate.content_with_placeholders_filled_in` also
normalises content.

Then it changes the non-templated route to also call
`str(BroadcastMessageTemplate)`, where previously it was passing the
content straight through.
2021-05-10 15:55:08 +01:00
Richard Baker
96cb30d640 Merge pull request #3235 from alphagov/dependabot/pip/eventlet-0.31.0
Bump eventlet from 0.30.2 to 0.31.0
2021-05-10 15:49:52 +01:00
Katie Smith
6fb3401ca7 Merge pull request #3233 from alphagov/broadcast-provider-types
Add a type table for broadcast providers
2021-05-10 11:41:39 +01:00
dependabot[bot]
c7ae2ee06a Bump eventlet from 0.30.2 to 0.31.0
Bumps [eventlet](https://github.com/eventlet/eventlet) from 0.30.2 to 0.31.0.
- [Release notes](https://github.com/eventlet/eventlet/releases)
- [Changelog](https://github.com/eventlet/eventlet/blob/master/NEWS)
- [Commits](https://github.com/eventlet/eventlet/compare/v0.30.2...v0.31.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-08 16:37:31 +00:00
Katie Smith
1767535def Allow service.allowed_broadcast_provider to be "all"
We want to replace the value `None` for
service.allowed_broadcast_provider with the value of "all". As a first
step, we need to allow both values. Once notifications-admin has been
changed to pass through "all" and all the data in the database has been
updated, we can update the code to stop supporting both values.
2021-05-06 15:32:02 +01:00
Katie Smith
aec631f208 Add a type table for broadcast providers
This adds a type table for broadcast providers, which is the pattern we
follow with our models (e.g. we have a `broadcast_channel_types` table).

As well as the four providers, the migration populates it with `all`
which is the value that will replace `null` in a later change.

It should be safe to add the foreign key constraint to the
`service_broadcast_settings` in the same migration since the column is
still nullable and we don't have data in that column that is not in the
types table.
2021-05-06 15:30:04 +01:00
Katie Smith
46fe3fca23 Merge pull request #3230 from alphagov/zipfile-names
Change letter zip file names for Insolvency Service letters
2021-05-06 13:57:18 +01:00
Ben Thorner
2ff187400d Merge pull request #3234 from alphagov/increase-sms-fail-thresh
Increase warning threshold for SMS failures
2021-05-06 10:52:38 +01:00
Katie Smith
8a34dccda0 Remove redundant join
This was left over from when we needed to tell if a notification was
sent by a crown or non-crown service.
2021-05-06 09:34:46 +01:00
Katie Smith
8365c749e4 Change letter zip file names for Insolvency Service letters
DVLA would like to be able to identify letters sent by the Insolvency
Service, so we are changing the zipfile name. They need all zipfile
names to have the same structure, so we can't just add a marker to files
sent by that service - we have to change all filenames.

The new format is like this:
`{NOTIFY}.{DATE}.{SEQUENCE_ID}.{UNIQUE_ID}.{SERVICE_ID}.{ORG_NAME}.{EXTENSION}`
2021-05-06 09:18:44 +01:00
Ben Thorner
bd45d788c0 Increase warning threshold for SMS failures
Second attempt [1]. This increases the threshold so:

- It's a more substantial amount of money lost (£16).

- It's 10% of the minimum free allowance for a service.

- It's greater than the threshold we have for TV numbers (500).

Having a higher threshold for this alert will help prevent wasted
effort investigating more negligible failures, and reduces the
ambiguity of whether we should take action: we should.

[1]: https://github.com/alphagov/notifications-api/pull/3221
2021-05-05 17:54:43 +01:00
Ben Thorner
4bbba69e0b Merge pull request #3232 from alphagov/rewrite-migration-readme
Rewrite migration README
2021-05-05 14:46:07 +01:00
Ben Thorner
618ce14842 Rewrite migration README
This clarifies how we generate migration filenames, and points to
the official docs and help commands, instead of repeating them.
2021-05-05 14:27:05 +01:00
Rebecca Law
0161adca06 Merge pull request #3228 from alphagov/sqlalchemy-update
SQLAlchemy update
2021-05-04 14:03:05 +01:00
Rebecca Law
590f29b28a SQLAlchemy 1.4 requires SQLALCHEMY_DATABASE_URI to use postgresql rather than postgres for the connection uri to the database.
When deploying to paas the database postgres environment variables are set using VCAP_SERVICES provided by PaaS. When we start up the app and set the properties we need to replace the postgres string with postgresql for the app to start up properly.
This wasn't caught locally or with the unit tests because we were setting this property with postgresql.
2021-04-29 13:49:37 +01:00
Rebecca Law
424796bdcc Add unit test for archiving a template with a template folder 2021-04-29 13:32:36 +01:00
Rebecca Law
4f196316aa Change the query to get the services to purge to use query on the db.Model rather than db.session.query.
`service_ids_to_purge` is a list of `row` object rather than a list of `UUID`.

NOTE: db.session.query(Service).filter(Service.id.notin_(services_with_data_retention)).all() would have also worked. It seems that only selecting attributes from the db.Model has caused the change.
2021-04-29 13:32:36 +01:00
Rebecca Law
68d28aa83b The update of SQLAlchemy 1.4.10 has caused some conflicts in our code. This PR fixes most of those conflicts.
- sqlalchemy.sql.expression.case must include an else statement.
- clearly define list of columns for inbound_sms_history insert, getting the list from InboundSmsHistory.__table__.c was causing data type errors.
- remove relationships when not needed, the foreign key relationship is established in the creation of the column. This will get rid of the warnings referenced here: http://sqlalche.me/e/14/qzyx.
- update queries now that he user relationship in ServiceUser db model has been removed.
- move the check that a template is archived to the view instead of the dao method. The check was clearing the session before the version history could be done.

Deleting notifications in the night tasks still needs to be
investigated. The raw sql is causing an error.
2021-04-29 13:32:36 +01:00
Pea Tyczynska
df19a91b7f Update error messages after SQLAlchemy version update 2021-04-29 13:32:36 +01:00
Pea Tyczynska
317ae5dbd4 Apply requirements update 2021-04-29 13:32:36 +01:00
pyup-bot
022c3bf178 Update sqlalchemy from 1.3.23 to 1.4.10 2021-04-29 13:32:36 +01:00
Ben Thorner
23f4ae32df Merge pull request #3214 from alphagov/check-broadcast-suspended
Enforce service suspension for broadcasts
2021-04-28 15:01:11 +01:00
Rebecca Law
d6b7b07767 Merge pull request #3226 from alphagov/revert-3219-pyup-scheduled-update-2021-04-21
Revert "Scheduled weekly dependency update for week 16"
2021-04-28 10:36:18 +01:00
Rebecca Law
85895a9e8b Revert "Scheduled weekly dependency update for week 16" 2021-04-28 10:17:16 +01:00
Rebecca Law
10b0554784 Merge pull request #3219 from alphagov/pyup-scheduled-update-2021-04-21
Scheduled weekly dependency update for week 16
2021-04-28 09:20:35 +01:00
David McDonald
2d345afab8 Merge pull request #3223 from alphagov/earlier-alerts
Make check-if-letters-still-in-created run at 7am
2021-04-27 17:29:12 +01:00
David McDonald
5b053d645b Merge pull request #3224 from alphagov/make-help
Add make help commands for commonly used tasks
2021-04-27 17:28:40 +01:00
Rebecca Law
be797ea513 Merge pull request #3215 from alphagov/add-unique-key-annual-billing
Add unique key on annual_billing for service_id + financial_year_start.
2021-04-27 14:14:10 +01:00
Ben Thorner
c716f5327d Merge pull request #3222 from alphagov/inject-request-id-send-task
Move request_id injection into send_task override
2021-04-27 12:51:19 +01:00
Rebecca Law
dcd08a0e45 Add unit test for archiving a template with a template folder 2021-04-27 12:30:50 +01:00
David McDonald
70c573ae08 Add make help commands for commonly used tasks
if you run `make help` or just `make` then you get a nice list of the
tasks that you can run (or at least, the ones with help text added to
them.

We were missing these for some of the key commands that a developer
would want to know about.

By adding help text to them, they will now show up in `make` or `make
help` and saves a developer needing to go either look in the README or
go look in the Makefile to figure out what commands are available.

Note, there is no particular convention around which commands have help
comments. I don't think we need to figure out this but at the least, the
ones which developers may want to run locally I think should show up.
2021-04-27 12:00:53 +01:00
David McDonald
f194231d87 Make check-if-letters-still-in-created run at 7am
If this alert goes off in the morning, it usually means we need to do
something, ideally quite quickly as it indicates a potential problem
with the sending of letters over to DVLA the night before.

Given this goes off at 9am at the moment, but actually some people start
work earlier, if we alert at 7am it means it will likely be looked at
earlier in the day and we can potentially fix any problems with letters
sooner than later.
2021-04-27 11:26:18 +01:00
Ben Thorner
99bc29418e Move request_id injection into send_task override
This applies the same change we made in other apps [1][2]. Adding
the override here is special, though, because it means the others
will now get triggered, since this app is the start of the chain
of tasks for a request. We will also retain existing request_id
tracing for tasks within this app, since "apply_async" calls the
"send_task" method internally, which is the one we're overriding.

[1]: 6f3c118a1e
[2]: 2e08b7aa95
2021-04-27 10:35:21 +01:00
Rebecca Law
f941768d8c Change the query to get the services to purge to use query on the db.Model rather than db.session.query.
`service_ids_to_purge` is a list of `row` object rather than a list of `UUID`.

NOTE: db.session.query(Service).filter(Service.id.notin_(services_with_data_retention)).all() would have also worked. It seems that only selecting attributes from the db.Model has caused the change.
2021-04-27 08:36:34 +01:00
Rebecca Law
5f26d16915 Merge pull request #3218 from alphagov/precomplied-letter-transation
Introduce transaction for precompiled letters
2021-04-26 13:10:31 +01:00
Rebecca Law
1b070d69a1 The update of SQLAlchemy 1.4.10 has caused some conflicts in our code. This PR fixes most of those conflicts.
- sqlalchemy.sql.expression.case must include an else statement.
- clearly define list of columns for inbound_sms_history insert, getting the list from InboundSmsHistory.__table__.c was causing data type errors.
- remove relationships when not needed, the foreign key relationship is established in the creation of the column. This will get rid of the warnings referenced here: http://sqlalche.me/e/14/qzyx.
- update queries now that he user relationship in ServiceUser db model has been removed.
- move the check that a template is archived to the view instead of the dao method. The check was clearing the session before the version history could be done.

Deleting notifications in the night tasks still needs to be
investigated. The raw sql is causing an error.
2021-04-26 11:50:30 +01:00
Pea Tyczynska
e1a626855d Update error messages after SQLAlchemy version update 2021-04-23 16:48:36 +01:00
Rebecca Law
490efad97a To avoid any table locks and contention on the production database we
are going to add the unique index concurrently. This only works if we
execute a commit first.
2021-04-23 15:16:18 +01:00
Chris Hill-Scott
b031b69bfa Merge pull request #3220 from alphagov/fix-broadcast-length-validation
Normalise broadcast content before validating length
2021-04-23 11:20:41 +01:00
Chris Hill-Scott
f8bca5765d Validate length of broadcast templates on creation
This is a belt-and-braces check because the admin app already checks
this. But since we do it for SMS already it makes sense to replicate it
for broadcast templates.
2021-04-22 17:11:31 +01:00
Pea Tyczynska
66127f3800 Apply requirements update 2021-04-22 16:59:15 +01:00
Chris Hill-Scott
7c6ae40034 Normalise broadcast content before validating length
This changes the content length validation of the internal API to match
the validation of the public broadcast API[1].

This removes the length check from JSONSchema, which isn’t sophisticated
enough to deal with things like normalising newlines or handling
different encodings.

The admin app should catch these errors before they’re raised here, but
it’s best to be belt and braces.

1.7ab0403ae7/app/v2/broadcast/post_broadcast.py (L53-L63)
2021-04-22 14:42:54 +01:00