Commit Graph

168 Commits

Author SHA1 Message Date
NIcholas Staples
e2d0d39ea7 Merge pull request #192 from alphagov/update_filter_for_multiple_arguments
Added functionality to allow filtering by multiple arguments.
2016-04-04 14:29:53 +01:00
Nicholas Staples
fac34aff10 Added functionality to allow filtering by multiple arguments.
Removed commented out code.
2016-04-04 13:21:51 +01:00
Rebecca Law
ec180980ee Merge branch 'master' into remove_email_safe 2016-04-01 13:45:21 +01:00
Nicholas Staples
514d490d2f No limit for live services. 2016-04-01 11:12:44 +01:00
Rebecca Law
8df4919029 The admin app now sends the email from when creating a service and when updating the service name.
This PR removes the need for the email_safe function. The api does not create the email_from field for the service.
Tests were updated to reflect this change.
2016-03-31 17:46:18 +01:00
Adam Shimali
7bc81528bb Post endpoint to create notificaition and get endpoint
to retrieve notification by id return data in shape more
consistent with other api endpoints.
2016-03-24 13:34:45 +00:00
Martyn Inglis
268819284f Merge branch 'master' into capture-delivery-outcomes
Conflicts:
	tests/app/notifications/test_rest.py
2016-03-21 13:32:31 +00:00
Martyn Inglis
00a04ce079 Removed SES debug line 2016-03-21 13:25:41 +00:00
Martyn Inglis
e0316d1881 Adds notification stats update into the callback process
- when a provider callback occurs and we update the status of the notification, also update the statistics table

Adds:
- Mapping object to the clients to handle mapping to various states from the response codes, this replaces the map.
- query lookup in the DAO to get the query based on response type / template type

Tests around rest class and dao to check correct updating of stats

Missing:
- multiple client callbacks will keep incrementing the counts of success/failure. This edge case needs to be handle in a future story.
2016-03-21 13:24:37 +00:00
Nicholas Staples
327f169575 Filtering added and tests working. 2016-03-21 12:37:34 +00:00
Nicholas Staples
f41d01780a whoops test fixes. 2016-03-16 17:01:58 +00:00
Nicholas Staples
16882961ad Added check for job in notifications json dump. 2016-03-15 14:57:15 +00:00
Nicholas Staples
356083e8ac Update schemas to return more details about the job and template for notifications. 2016-03-15 14:24:10 +00:00
Martyn Inglis
3192f5f6d1 SES Callback testing
- SES/AWS JSON is horrible and not valid.
- JSON in tests did not test accurately what it looked like in reality
- Using very odd looking bytes/strings as input into API which is more accurate
2016-03-14 14:49:02 +00:00
Martyn Inglis
1ff4ebad5c Merge branch 'master' into client-callbacks
Conflicts:
	app/notifications/rest.py
	tests/app/celery/test_tasks.py
2016-03-14 11:45:21 +00:00
Rebecca Law
e055590b07 Changed db queries to use one, which throws NoResultFound exception, this exception is dealt with in our error handlers.
Now a lot of the if none checks can be removed.
2016-03-11 12:39:55 +00:00
Martyn Inglis
62a7b8bcd0 Update notification status by message reference
- SES sends a reference to allow us to identify the notification
- use this to update status

If source of email is one of our internal emails (invites or validations) - don't try and update a notification.
2016-03-11 10:19:40 +00:00
Martyn Inglis
f88f86a924 Endpoint to allow SES updates to occur
- update notification with delivery state
2016-03-10 17:29:17 +00:00
Martyn Inglis
2922712f0b Make sms code task use a reference too
- makes the fire text callback behave in consistent way
2016-03-10 15:51:11 +00:00
Martyn Inglis
1f22f2b7cc Updates to fire text integration:
- client updated to raise errors with fire text error codes/messages

New endpoint
- /notifications/sms/firetext
For delivery notifications to be sent to.
2016-03-10 15:40:41 +00:00
Martyn Inglis
fd7eb54d10 Merge branch 'master' into delete-expired-things
Conflicts:
	app/celery/tasks.py
	tests/app/celery/test_tasks.py
	tests/app/dao/test_notification_dao.py
2016-03-10 09:48:29 +00:00
Martyn Inglis
976a4c06e3 Renamed some files and fixed a bug on deleting the failed notifications 2016-03-10 09:34:27 +00:00
Martyn Inglis
2a13fe4a54 Merge branch 'master' into rate-limit
Conflicts:
	app/celery/tasks.py
	tests/app/celery/test_tasks.py
2016-03-09 14:16:59 +00:00
Martyn Inglis
61af70a392 Some more tests around edge cases 2016-03-09 11:35:12 +00:00
Martyn Inglis
61a0cf32c8 Ensure clients have rate limit enforced
- rate limiting is a hard number per day
- not limited in terms of rate of request
- limit is a single number held against the service
- every notification counts against the limit, regardless of type
- return a 429 if limit exceeded.
2016-03-09 11:06:37 +00:00
Rebecca Law
d0c5977b9d Fix extra space in test 2016-03-09 09:57:14 +00:00
Rebecca Law
49198b26e7 Merge branch 'master' into reset-password
Conflicts:
	app/schemas.py
	tests/app/celery/test_tasks.py
2016-03-09 09:36:57 +00:00
NIcholas Staples
528f570ab6 Merge pull request #141 from alphagov/capture-aggregate-data
Capture aggregate data
2016-03-08 17:54:39 +00:00
Rebecca Law
114cfa6b17 Use the validation error message from the InvalidEmailError 2016-03-08 17:46:00 +00:00
Martyn Inglis
e07d16e8c6 Fixed up dates so that we respect mills 2016-03-08 17:45:37 +00:00
Chris Hill-Scott
8323757441 Accept phone numbers in any valid format
This uses the `format_phone_number` method from utils to output phone numbers
in a consistent format. It is added to the schemas, so will be applied before
the API tries to do anything with a provided phone number.

So now the API will accept any of the following:
- 07123456789
- 07123 456789
- 07123-456-789
- 00447123456789
- 00 44 7123456789
- +447123456789
- +44 7123 456 789
- +44 (0)7123 456 789

…but the API will always hand off phone numbers to 3rd party APIs in the format
- +447123456789

The test for this is slightly convoluted, because template IDs are still
database IDs, and can’t consistently be mocked, therefore we have to ignore that
part of the call to `encrypt()`.
2016-03-08 09:47:21 +00:00
Chris Hill-Scott
157b385327 Use validation of recipients from utils
This was added to utils in 5914da74f1

This means that:
- we are doing the exact same validation in the API and admin app
- we are actually validating phone numbers for the correct format (hence all the
  changes to the tests)
2016-03-08 09:47:21 +00:00
Chris Hill-Scott
0e5d72494e Prefix all SMS messages with service name
Implements https://github.com/alphagov/notifications-utils/pull/4
2016-03-02 11:14:32 +00:00
Chris Hill-Scott
68eaacaafb Accept and validate personalisation
This commit allows the send notification endpoint to accept an extra parameter,
`personalisation`, the contents of which will be used (later) to replace the
placeholders in the template.

It does validation in the following places:
- at the schema level, to validate the type and (optional) presence of
  personalisation
- at the endpoint, to check whether the personalisation provided matches exactly
  the placeholders in the template

It does not do validation when processing CSV files, as these are assumed to
already have been validated by the admin app.

It explicitly does not persist either the names of the placeholders (these
should always be derived from the template contents unless it really becomes a
performance concern) or the values of the placeholders (because they might be
personal data).
2016-03-02 08:59:34 +00:00
Martyn Inglis
6d345c1dfc Fixed ordering of the notifications test
- was backwards
2016-03-01 14:58:27 +00:00
Martyn Inglis
c5a993ead1 Fetch endpoints for notifications
- includes check on token type to ensure clients can perform admin style fetches
2016-03-01 13:30:10 +00:00
Nicholas Staples
16e1ecb134 Working permissions and all tests passing.
Remove print statements.

Fix for review comments.
2016-02-26 15:00:29 +00:00
Martyn Inglis
0b63477e49 Removed now unused notification for job endpoints
- this is now handled in the tasks
2016-02-25 11:35:32 +00:00
Martyn Inglis
44632c36d3 Add sender name to the notification
- also ensure that the created time is handled properly
2016-02-25 11:23:04 +00:00
Martyn Inglis
b3884e2d6c Move job processing into celery
- brings boto S3 into new AWS folder
- CSV processing utils method

Rejigs the jobs rest endpoint - removes some now unused endpoints,

Calls to the task with the job, job processing in task, delegating SMS calls to the sms task
2016-02-24 17:12:30 +00:00
Martyn Inglis
1667f82df1 Removed some unused template dao methods 2016-02-24 11:51:02 +00:00
Martyn Inglis
6ac6a64b46 Tests for email job notifications endpoint 2016-02-24 11:44:11 +00:00
Martyn Inglis
8389976250 Use service ID, not from token to build notification 2016-02-24 11:11:02 +00:00
Martyn Inglis
b0609b1813 More refactors
- single base method to send notifications
- knows about service id (present if job based)
- knows about jobs - if needed
- knows about type

Does the right thing

Was lots of shared code around error checking now in one place.
2016-02-24 09:55:05 +00:00
Martyn Inglis
0007c69972 Restored code to share sms creation logic between:
- sms for API calls
- sms for Jobs
2016-02-24 09:23:21 +00:00
Martyn Inglis
201c2d01ba Task is the same whether job based or not
- use notification to build action
- notification has job
- based in encrypted blob
2016-02-23 17:39:08 +00:00
Martyn Inglis
635debb5a6 Moved the sending sms for a job into celery tasks 2016-02-23 17:30:50 +00:00
Martyn Inglis
b01782bbe6 Send Email via the API
- uses the new subject/email from fields present on the templates / service tables
- brings the send email api call into line with the sms one.
- same fields (to/template_id)
- same rules regarding restricted services
- wired in as a task into celery

Requires
- new celery queue
- new env property (NOTIFY_EMAIL_DOMAIN)
2016-02-22 17:17:29 +00:00
Martyn Inglis
e0e47b40fc Setup celery config 2016-02-17 10:22:25 +00:00
Martyn Inglis
85a8e6d2b4 Added moto back for methods not yet celery'd 2016-02-17 09:47:34 +00:00