Commit Graph

7880 Commits

Author SHA1 Message Date
Chris Hill-Scott
4e009af2f7 Bump utils to 43.5.8
Changes:
https://github.com/alphagov/notifications-utils/compare/43.5.7...43.5.8
2020-12-18 14:35:16 +00:00
Pea M. Tyczynska
519568970c Merge pull request #3059 from alphagov/cancel_broadcast_cbc
Add cancel routes to cbc proxy clients
2020-12-18 12:09:49 +00:00
Pea M. Tyczynska
bb41cabeb6 Merge pull request #3065 from alphagov/up-email-size-limit
Increase email size limit to 2MBby pulling in new utils
2020-12-16 16:14:58 +00:00
Pea Tyczynska
4fc3f95c41 Increase email size limit to 2MBby pulling in new utils
This is because GOV.UK has hit the email size limit with their
weekly digest email.
2020-12-16 15:59:49 +00:00
David McDonald
e35ea57ba2 Do not delete letters if not in final state
A few weeks ago, we deleted some pdf letters that had reached their
retention period. However, these letters were in the 'created' state so
it's very arguable that we should not have deleted them because we were
expecting to resend them and were unable to. Part of the reason for this
is that we marked the letters back to `created` as the status but we did
not nullify the `sent_at` timestamp, meaning the check on
ebb43082d5/app/dao/notifications_dao.py (L346)
did not catch it. Regardless of that check, which controls whether the
files were removed from S3, they were also archived into the
`notification_history` table as by default.

This commit does changes our code such that letters that are not in
their final state do not go through our retention process. This could
mean they violate their retention policy but that is likely the lesser
of two evils (the other being we delete them and are unable to resend
them).

Note, `sending` letters have been included in those not to be removed
because there is a risk that we give the letter to DVLA and put it in
`sending` but then they come back to us later telling us they've had
problems and require us to resend.
2020-12-16 10:50:11 +00:00
David McDonald
47e146f010 Move variable out of loop that didn't need to be 2020-12-16 10:40:30 +00:00
David McDonald
1bf9b29905 Document behaviour of s3 letter deleting
The behaviour was a bit of opaque so I have added tests around it so
it's clear what it is doing and why. No functionality has changed
2020-12-16 10:39:31 +00:00
David McDonald
219023f4c6 Fix test that was passing unintentionally
This test was added in
ebb43082d5

However, there are a few problems with it

1. The test name doesn't seem to match what the code is doing. It looks
   like instead that it is NOT trying to delete from s3 when the letter
   has not been sent and therefore I've updated the test name as such.

2. `delete_notifications_older_than_retention_by_type` was being called
   with `email` as it's argument which doesn't match. This is a test for
   letters. It definitely wouldn't do any looking in s3 for emails.

3. `created_at` needed bumping back into the past, past the default 7
   days retention so these letters would be considered old enough to
   delete

4. For the letter to not be sent, it needs to be in `created`, not in
   `sending` so I have updated the status. Note, there could be other
   statuses which class as 'not sent' but this is the most obvious one
   to test with
2020-12-15 09:48:08 +00:00
Pea Tyczynska
4758d8c4cb Format message_number for references
In IBAG format for broadcasts, we need to give sequential number
of previous message, and it needs to be formatted as a hex padded
with zeroes to be 8 character long.

This commit adds the necessary formatting.
2020-12-14 18:21:28 +00:00
Pea Tyczynska
45b806f6db Remove unused args from cancel broadcast call in tasks 2020-12-14 11:31:05 +00:00
Pea Tyczynska
35a212d907 Add cancel routes to cbc proxy clients
Also clean the code up a bit.
2020-12-11 18:52:54 +00:00
Chris Hill-Scott
34e8da7285 Merge pull request #3058 from alphagov/bump-utils-43.5.6
Bump utils to 43.5.6
2020-12-11 16:11:51 +00:00
Chris Hill-Scott
2165cbaf76 Bump utils to 43.5.6
Changes:
https://github.com/alphagov/notifications-utils/compare/43.5.4...43.5.6
2020-12-11 10:56:06 +00:00
Richard Baker
8a3e90ae39 Merge pull request #3057 from alphagov/fix_cap_message_format
Set cbc proxy message_format to "cap"
2020-12-09 17:29:24 +00:00
Richard Baker
4dd37acecb Set cbc proxy message_format to cap
The CBC proxy lambda expects the message_format parameter to be one of `cap` or `ibag`.

Signed-off-by: Richard Baker <richard.baker@digital.cabinet-office.gov.uk>
2020-12-09 17:10:40 +00:00
Pea M. Tyczynska
a70b7c521e Merge pull request #3053 from alphagov/ibag-message-number
Add sequential message number to broadcast provider messages
2020-12-09 13:02:25 +00:00
Pea Tyczynska
ac3f56f4ed Delete unneeded code form migration 2020-12-09 12:31:50 +00:00
Pea Tyczynska
def7a16765 Establish relation between provider message and message number
this is so we can access brodcast_provider_message_number from
BroadcastProviderMessage object
2020-12-09 11:41:22 +00:00
Pea Tyczynska
8af4b27fd6 Separate functions for cbc clients
Also move message_format to the clients.
2020-12-09 11:13:50 +00:00
Pea Tyczynska
553565bc91 Send message format to CBC
Either cap or ibag
2020-12-08 11:15:26 +00:00
Pea Tyczynska
9e4176ac50 Add Vodafone client to list of allowed CBCs 2020-12-08 09:51:21 +00:00
Leo Hemsted
f5ef4cdf99 Merge pull request #3055 from alphagov/put-manifest-in-tmp-folder
put manifest in tmp folder
2020-12-07 18:39:33 +00:00
Leo Hemsted
9e5920472f put manifest in tmp folder
for reasons unknown, using a file descriptor no longer works on
concourse (or in that docker container generally). It might be a change
within cf-cli v7 vs v6.

Either way, it does't work, so use a temporary file. Clean up the
temporary file afterwards.

If the command fails, the temporary file will still stick around, so
I've added the file to the /tmp/ folder instead. it's full of secret
keys and things so if you do have a deployment error while running
locally, you should make sure you clean up the file (make cf-rollback
and make clean will both do this for you).
2020-12-07 18:27:22 +00:00
Leo Hemsted
6b01546c20 Merge pull request #3054 from alphagov/utils-bump
bump utils
2020-12-07 16:07:44 +00:00
Leo Hemsted
9502f17d84 flake8 fixes
a stricter flake8 bump. mostly things around f strings and format
strings, but a couple of bad placeholder names in loops
2020-12-07 15:24:02 +00:00
Leo Hemsted
d6555d887c provide a location for create_bucket
this is required when the boto3.resource itself is given a region
2020-12-07 15:03:41 +00:00
Leo Hemsted
45cc74bcc0 bump test requirements 2020-12-07 14:51:05 +00:00
Leo Hemsted
dc881b262e bump utils
this is to fix pip errors due to bad requirements
2020-12-07 14:35:06 +00:00
Leo Hemsted
db7759a9d8 Merge pull request #3052 from alphagov/v7-makefile
use cf-cli@v7 in makefile
2020-12-07 13:51:33 +00:00
Pea Tyczynska
2952b70930 Only create sequential numbers for Vodafone messages 2020-12-07 13:13:13 +00:00
Pea Tyczynska
932a09fe5b Pass message_number to proxy clients 2020-12-07 13:13:12 +00:00
Pea Tyczynska
e95dc9450e Include message number in send_broadcast_provider_message 2020-12-07 13:13:12 +00:00
Pea Tyczynska
a186d2d296 Format sequential number into an 8 char long hex
As per Vodafone spec for ibag format message number
2020-12-07 13:13:11 +00:00
Pea Tyczynska
b34bffaae6 Sends sequential number to Vodafone as link test 2020-12-07 13:13:11 +00:00
Pea Tyczynska
e6824dc3ff Broadcast provider message created with a sequential number
This is for the IBAG format (similar to CAP format, but proprietary)
used in the XMLs that we exchange with broadcast providers (specifically
Vodafone).
2020-12-07 13:13:10 +00:00
Pea Tyczynska
2a04148ea1 Add sequential numbering for broadcast messages
We need that to send broadcast messages using proprietary IBAG
format that Vodafone currently uses.
2020-12-07 13:13:10 +00:00
Leo Hemsted
b019419a5d use cf-cli@v7 in makefile
a bug in cf-cli v6 caused us to get rate limited, one solution to this
is to bump the version of cf-cli we're using to version 7. This has a
few syntax changes as the old v3 commands become mainline.

To upgrade locally, grab the latest version from brew.

```sh
brew install cloudfoundry/tap/cf-cli@7
```
2020-12-07 11:54:12 +00:00
Leo Hemsted
6405c1695f Merge pull request #3051 from alphagov/provider-per-service
Restrict providers per service
2020-12-04 09:59:24 +00:00
Leo Hemsted
fd335e3d8b move available provider logic to the service model
make sure it's in an accessible place so we don't end up duplicating our
work
2020-12-03 22:50:50 +00:00
Leo Hemsted
72f8a15d4f respect service broadcast provider restrictions when sending 2020-12-03 13:39:09 +00:00
Leo Hemsted
0ef063ab14 return allowed_broadcast_provider via get by service id 2020-12-03 12:38:31 +00:00
Leo Hemsted
0bbd00d2a5 return service restrictions from the service endpoint 2020-12-03 12:38:04 +00:00
Leo Hemsted
1a083134fa add service broadcast provider restriction table
some services only send to one provider. This is a platform admin
setting to allow us to test integrations and providers manually without
affecting other broadcasts from different services.

one-to-one - a service can either send to all as normal, or send to only
one provider.
2020-12-03 12:38:04 +00:00
Chris Hill-Scott
3bf936b782 Merge pull request #3049 from alphagov/jobs-from-contact-lists-uploads
Don’t return jobs sent from contact lists (uploads page edition)
2020-12-01 16:56:30 +00:00
Chris Hill-Scott
682cbc5130 Don’t return jobs sent from contact lists
Now that we’re grouping jobs sent from contact lists within their
parent, they shouldn’t also be listed on the jobs page at the top level.

The jobs page uses the uploads API, not the jobs API, so this commit
makes sure that filtering is happening in the proper place.
2020-12-01 15:26:36 +00:00
Chris Hill-Scott
10e1fe6902 Revert "Don’t return jobs sent from contact lists"
This reverts commit 061c0a0050.
2020-12-01 15:18:32 +00:00
Chris Hill-Scott
5bc8d8609b Merge pull request #2842 from alphagov/dont-return-jobs-from-contact-list
Don’t return jobs sent from contact lists
2020-12-01 14:48:04 +00:00
David McDonald
cf0d424910 Merge pull request #3048 from alphagov/uuid-to-string
Fix comparison of uuid to string
2020-12-01 12:21:20 +00:00
Chris Hill-Scott
061c0a0050 Don’t return jobs sent from contact lists
Now that we’re grouping jobs sent from contact lists within their
parent, they shouldn’t also be listed on the jobs page at the top level.
2020-12-01 11:56:34 +00:00
David McDonald
bb6e671bd1 Fix comparison of uuid to string
`service.id` is a uuid so will not be matched to anything in
`current_app.config.get('HIGH_VOLUME_SERVICE')` because that is a list
of strings.

This is why we are never falling into the first if statement and having
any metrics for high volume services on our dashboards at the moment.

Note, I had taken the existing line from the `post_notification`
endpoint, but that is using a serialised service which already has the
UUID converted to a string.
2020-12-01 11:16:15 +00:00