Commit Graph

815 Commits

Author SHA1 Message Date
Martyn Inglis
f8ac14ea30 Update model
- adds email_from field to the service model
- adds subject_line to the template model

These are unique and not null fields, so there is a migration here for email_from to populate it.
2016-02-19 15:52:19 +00:00
Nicholas Staples
0396148853 Permissions added. 2016-02-19 14:47:45 +00:00
Rebecca Law
17d14f291e Refactor user/<user_id>/code into two endpoints.
- Created new endpoint user/<user_id>/sms-code to send the sms verification code to the user.
- Create new endpoirtn user/<user_id>/email-code to send the email verifcation code to the user.
- Marked the old methods, schema, tests with a TODO to be deleted when the admin app is no longer sending messages to /user/<user_id>/code
- Added error handlers for DataError and NoResultFound. Data error catches invalid input errors.
- Added error handler for SqlAlchemyError which catches any other database errors.
- Removed the need for the try catches around the db calls in the user endpoints with the addition of the db error handlers.
- We may want to wrap db excpetions in the dao, if we want the No results found message to be more specific and say no result found for user.
2016-02-19 11:37:35 +00:00
Rebecca Law
9ea2acfdae Use dashes in the celery queue names 2016-02-18 11:18:35 +00:00
minglis
9b99782662 Merge pull request #83 from alphagov/celery-send-email-code
Celery send email code
2016-02-18 11:03:23 +00:00
Rebecca Law
4d9d511575 Merge pull request #81 from alphagov/celery-send-sms-code
Use Celery to send sms code
2016-02-18 10:51:16 +00:00
Rebecca Law
aff948e9ca Merge branch 'celery-send-sms-code' into celery-send-email-code
Conflicts:
	app/celery/tasks.py
	app/user/rest.py
	scripts/run_celery.sh
2016-02-18 10:50:14 +00:00
Rebecca Law
3ce6758f3e Change names for clarity sake.
Rename test.
What we do when the validation_code fails to send is still to be decided.
2016-02-18 09:59:18 +00:00
Rebecca Law
c1df61a7d4 Use celery to send the email verification code. 2016-02-18 09:52:27 +00:00
Rebecca Law
9073814d9f I have an issue with the test, not sure why? 2016-02-17 17:48:23 +00:00
Adam Shimali
4f33b6f406 Wire up error handlers.
Replace some 400s with more appropriate 500s.

DAO methods that cause unexpected exceptions get caught and
logged by errors.py 500 error handler.
2016-02-17 17:04:50 +00:00
Rebecca Law
66cf6cfd30 Use Firetext client 2016-02-17 15:52:09 +00:00
Rebecca Law
7afa87c367 Merge branch 'master' into celery-send-sms-code
Conflicts:
	tests/app/celery/test_tasks.py
2016-02-17 15:43:57 +00:00
Rebecca Law
d022d036dc Celery task to send the sms verify code.
Each celery task will use it's own queue.
2016-02-17 15:41:33 +00:00
Martyn Inglis
837c9b7cdb Removed logging, and make fire text only client. 2016-02-17 13:59:01 +00:00
Martyn Inglis
226459132a Basic (Very basic) implementation of the fire text API.
[https://www.firetext.co.uk/docs#sendingsms](https://www.firetext.co.uk/docs#sendingsms)

Not to be merged. This API has a limit on it at the moment that will need to be removed before it is used in anger.
2016-02-17 12:57:51 +00:00
Martyn Inglis
95cdfe08d1 Updated logging in run-celery script to log to application logs
- poll every second
- visibility of 1 minute
2016-02-17 11:18:27 +00:00
Martyn Inglis
e0e47b40fc Setup celery config 2016-02-17 10:22:25 +00:00
Martyn Inglis
73d0e67e68 Removed alpha api client 2016-02-17 09:22:06 +00:00
Martyn Inglis
cb265896a7 Merge branch 'master' into move-sms-notifications-into-celery
Conflicts:
	app/__init__.py
	tests/conftest.py
2016-02-17 09:14:37 +00:00
Martyn Inglis
1311af5920 Twilio client takes a 'to' number not a notification 2016-02-17 09:12:13 +00:00
Martyn Inglis
a2341be0e2 Don't send the SMS if we have failed to save in the database 2016-02-16 17:42:04 +00:00
Martyn Inglis
0933e5c647 Building tests for the tasks class 2016-02-16 17:17:02 +00:00
Rebecca Law
08ba5de61b Update config
Source the configuration from an environment file, this way it is similar to how the aws environment works
2016-02-16 16:01:50 +00:00
Martyn Inglis
18d63e241b Extracted serialiser for encryption into a flask module
- allows mocking easier
- shared across methods
- not built everytime
2016-02-16 15:28:30 +00:00
Martyn Inglis
e42da7dd54 Fixing up tests to validate the call to the celery tasks.
- mocker used to test call or otherwise of the task
- no new tests just a spring clean
2016-02-16 14:06:56 +00:00
Martyn Inglis
655beddba6 Fixed up the get_notitication endpoint
- returns a notification
2016-02-16 11:22:44 +00:00
Nicholas Staples
20650a91e0 Update to config to pull out from email address. 2016-02-16 11:10:02 +00:00
Martyn Inglis
223cb8c2dd Made SMS messages go through celery
- twilio client pulled in from delivery app
- made method to perform task
2016-02-15 16:01:14 +00:00
Rebecca Law
fcaed04918 Fix validation of template for service.
When the delivery app creates the sms on behalf of the service,
the validation was failing.
2016-02-15 15:02:19 +00:00
Martyn Inglis
ffbe94f390 Merge branch 'master' into celery-spike
Conflicts:
	app/notifications/rest.py
2016-02-15 11:12:07 +00:00
Martyn Inglis
16c5e7bf10 Celery task added 2016-02-15 11:11:20 +00:00
Nicholas Staples
1eb18e7f07 Code review fix. 2016-02-12 14:08:48 +00:00
Nicholas Staples
918c561726 Code added to now check service id matches the authorization token service for sending an sms. 2016-02-12 11:13:54 +00:00
Martyn Inglis
fcc1585fdf Merge branch 'master' into celery-spike
Conflicts:
	app/__init__.py
	app/notifications/rest.py
	config.py
	wsgi.py
2016-02-12 09:36:49 +00:00
Rebecca Law
a01828a6d0 Return notification_id on create notification endpoints
- /notification/sms
 - /notification/email
 - /notificaiton/sms/service/<service_id>
Update message attribute on SQS to notification_id from message_id
2016-02-10 12:46:52 +00:00
Adam Shimali
3a2cfc96e6 job on notification now nullable. 2016-02-10 11:08:24 +00:00
Martyn Inglis
d38ba0d36a bumped client version 2016-02-09 18:48:02 +00:00
Adam Shimali
e6a7e07505 Fix for create job id on api side 2016-02-09 18:28:28 +00:00
Nicholas Staples
1b25a3c762 Removed alpha client imports. 2016-02-09 16:13:48 +00:00
Nicholas Staples
68b6444eed Comment added for missing code. 2016-02-09 16:02:38 +00:00
Nicholas Staples
bd947d0743 Merge remote-tracking branch 'origin/master' into remove_alpha_client_from_api 2016-02-09 15:54:21 +00:00
Adam Shimali
17e5e70f6c [WIP] Added endpoints under /job for creating, updating and reading
notification status.
2016-02-09 14:17:42 +00:00
Martyn Inglis
fb41acdac9 Celery tests 2016-02-09 13:31:45 +00:00
Adam Shimali
e5e049d735 Added service and template relationship to notification model.
This makes it more consistent with other model classes with respect
to marhmallow serialisation/deserialisation.
2016-02-09 12:48:27 +00:00
Adam Shimali
c7121be5a2 [WIP] New model class and dao for notification. This will be used for
recording status and outcome of sending notifications.
2016-02-09 12:03:40 +00:00
Nicholas Staples
2fda7ee59b Alpha client removed from code. Tests fixed but will wait till other notifications jobs are done before creating a pull request. 2016-02-09 11:38:57 +00:00
Adam Shimali
0580f5ab06 New endpoint for delivery app to use.
Once removal of code that uses existing alpha is done, then
duplicated code from /notifications/sms and the new endpoint
can be merged.

Job id is now avaiable in notificaiton but is not used yet.
2016-02-08 14:54:15 +00:00
Rebecca Law
416dd00ac8 Added a test for the case when there is no secret for the api client.
Fix codestyle
2016-02-08 11:33:24 +00:00
Rebecca Law
877a8a0411 Added logging for the authentication errors.
Moved the "no api secret" error message to the end and only create it if there are no
api client secrets
2016-02-08 11:10:54 +00:00