Commit Graph

96 Commits

Author SHA1 Message Date
Rebecca Law
c8c0f95dd2 Merge branch 'master' into add-template-version
Conflicts:
	tests/app/dao/test_notification_dao.py
2016-05-12 09:49:35 +01:00
Rebecca Law
f72f5aba05 [WIP]
Start to add template_version to jobs and notification
2016-05-11 17:04:51 +01:00
Martyn Inglis
b22c52131d Fixing up a couple of pull request comments
- python style if
- renamed the relationships
2016-05-11 15:36:17 +01:00
Martyn Inglis
571686b638 Ensure that the primary provider is used in all tasks 2016-05-10 09:04:22 +01:00
Chris Hill-Scott
c96c1799f9 Process CSV files with column headers of any case
Implements and depends on:
https://github.com/alphagov/notifications-utils/pull/27

Should be merged and deployed before the same change in the admin app.
2016-04-29 17:24:00 +01:00
Rebecca Law
559496a518 Merge pull request #275 from alphagov/fix-auth-bug
This pull request fixes a bug in authentication.
2016-04-29 14:52:20 +01:00
Rebecca Law
11c4696775 Update to test as per review comments.
However, I am curious if there is evidence that using fake_uuid over creating one in the test is actually faster.
2016-04-29 14:36:10 +01:00
Nicholas Staples
f71dbe9c0f Message limit added and all tests passing. 2016-04-29 10:36:59 +01:00
Chris Hill-Scott
b282f5015b Merge pull request #262 from alphagov/email-from-name
Send emails with a friendly from name
2016-04-26 11:24:49 +01:00
Chris Hill-Scott
eeaeacbf0b Remove send email code task
We don’t send email codes any more
2016-04-26 08:55:09 +01:00
Chris Hill-Scott
ac0fa5b211 Send emails with a friendly from name
It’s nicer to have emails with a sender name, as well as the raw email
address.

Amazon SES can acheive this by using the format
```
"Sender name" <sender.name@domain.com>
```
— http://docs.aws.amazon.com/ses/latest/DeveloperGuide/email-format.html
We also have to remove all non-ASCII characters from the sender name,
because SMTP only supports 7-bit ASCII:

> A field name MUST be composed of printable US-ASCII characters (i.e.,
> characters that have values between 33 and 126, inclusive), except
> colon.

— http://www.ietf.org/rfc/rfc5322.txt

We use the service name as the sender name when:
- sending emails from the API
- sending emails from a CSV file

We use GOV.UK Notify as the sender name when:
- sending invitation emails
- sending password reset emails
2016-04-25 16:57:17 +01:00
Nicholas Staples
3b1423a2ea Provider Statistics added.
Rates command added with a test.

Updated to include added migration.
2016-04-21 13:47:04 +01:00
Nicholas Staples
bee23281fc Updated text send to user for the authorization code. 2016-04-20 12:02:17 +01:00
Nicholas Staples
f681d40366 Character count added and tests passing.
Remove sql restriction for count to not be null.
2016-04-15 16:31:13 +01:00
Chris Hill-Scott
02f903b44c Stop GOV.UK becoming a link in email clients
Implements (and depends on)
https://github.com/alphagov/notifications-utils/pull/24

Works for:
- emails we send to users, eg invite, forgot password
- email templates that users have created
2016-04-15 12:33:58 +01:00
Nicholas Staples
1b76646170 Working placeholders in subject with upgraded notifications-utils.
Fix test.
2016-04-13 15:53:27 +01:00
Nicholas Staples
7fa33a52a9 Fixed bug with deleting the 'delivered' notifications. 2016-04-13 12:49:38 +01:00
Nicholas Staples
90f0505a3d Update limit to message_limit.
Further db changes and updates.

Remove traceback print out.

Fix bug in passing template id to a task.
2016-04-11 16:53:40 +01:00
Nicholas Staples
143d1b0db8 Updated to retrieve csv upload from new bucket.
Fix test errors.
2016-04-07 14:10:30 +01:00
Rebecca Law
340f8ceaf6 Update mmg send_sms to include cid and request headers
Use mmg to send_sms
2016-04-06 17:35:14 +01:00
Rebecca Law
323b2ff537 Use MMG client for send-sms 2016-04-06 15:56:34 +01:00
Rebecca Law
e8d5a9292a Merge branch 'master' into integrate_MMG
Conflicts:
	app/notifications/rest.py
2016-04-06 14:58:13 +01:00
Rebecca Law
4806123d5c Add process_mmg_responses
Refactor process_firetext_responses
Removed the abstract ClientResponses for firetext and mmg. There is a map for each response to handle the status codes sent by each client.
Since MMG has about 20 different status code, none of which seem to be a pending state (unlike firetext that has 3 status one for pending - network delay).
For MMG status codes, look for 00 as successful, everything else is assumed to be a failure.
2016-04-06 14:31:33 +01:00
Chris Hill-Scott
044f2b7896 Merge pull request #203 from alphagov/double-check-restricted-mode
Catch sending to restricted recipients in Celery
2016-04-06 13:10:45 +01:00
Chris Hill-Scott
eef6d80ae2 Catch sending to restricted recipients in Celery
The Celery `send_sms` and `send_email` tasks _could_ assume that all the
recipients it gets are safe, because they have been checked either:
- when the admin app processes the CSV
- in the `/notifications/sms|email` endpoint

*However*, it’s probably safer to make the check again when the Celery
task run and passes the message off to the third party.

This also means that changing a service _back_ to restricted would have
an effect on messages that were queued, as well as all subsequent
messages.

This commit:
- restores the test that was removed here:
  e56aee5d1d (diff-e5627619e387fccc04783c32a23e6859L346)
- adds checks back into the Celery tasks for sending email and SMS,
  using the `allowed_to_send_to` function that was introduced into utils
  in https://github.com/alphagov/notifications-utils/pull/16
2016-04-05 15:11:27 +01:00
NIcholas Staples
2e09ead30f Merge pull request #198 from alphagov/retain_all_notifications_for_7_days
Successful notifications are deleted after a week now. All tests pass…
2016-04-05 15:05:58 +01:00
Nicholas Staples
4cc0028b01 Remove csv after process job is finished.
Fixed new tests.
2016-04-05 14:55:03 +01:00
Nicholas Staples
4d15409781 Successful notifications are deleted after a week now. All tests passing. 2016-04-05 11:07:21 +01:00
Chris Hill-Scott
e56aee5d1d Validate recipient for restricted service w/ utils
Implements
https://github.com/alphagov/notifications-utils/pull/16

Once
https://github.com/alphagov/notifications-admin/pull/376
is merged it will no longer be possible for a user to upload a CSV file
containing recipients that they’re not allowed to send to.

So this commit also removes any restricted service checks in the task,
because any public phone numbers/email addresses no longer have any way
of reach this point if the service is restricted.
2016-04-04 20:10:19 +01:00
Rebecca Law
69697388d7 Initial set up for mmg client integration 2016-04-01 16:42:31 +01:00
Adam Shimali
ca9c886c3e [WIP] On create of notification. Upsert record for template stats
recording usages of template by day.
2016-03-31 15:57:50 +01:00
Chris Hill-Scott
e3ae81bd0a Strip trailing CSV rows, relax phone validation
Implements (and depends on):
- https://github.com/alphagov/notifications-utils/pull/14
- https://github.com/alphagov/notifications-utils/pull/15
2016-03-24 20:30:15 +00:00
Chris Hill-Scott
a0022455f0 Merge pull request #173 from alphagov/email-wrapper
Add HTML email
2016-03-18 15:42:32 +00:00
Chris Hill-Scott
f3ddf1f456 Add HTML email
Make the SES client optionally pass through HTML and text body, as per:
http://docs.aws.amazon.com/ses/latest/APIReference/API_Body.html

Gets the message as HTML from:
https://github.com/alphagov/notifications-utils/pull/12
2016-03-18 15:26:32 +00:00
Adam Shimali
2d1d883283 Added task for sending email verification links out on intial
registration.

Left original email code endpoint in as it is still used for things like
email change.
2016-03-17 15:21:04 +00:00
Rebecca Law
4268f8453b Use the same validation in the endpoint and the task to validate the phone number is ok to send to.
Format the phone number before sending it to the sms provider.
2016-03-16 13:36:46 +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
Martyn Inglis
fd973179cc - Commit session on job update
- log at exception level
2016-03-14 11:34:09 +00:00
Chris Hill-Scott
d6cf15469f Be agnostic about format when comparing phone #s
If a service is in restricted mode then a user can’t send messages to anyone
other than themselves and members of their team. To do this the API has to
compare the numbers they are sending to with those of their team members.

It will (falsely) say the numbers do not match if they are in a different
format, eg 07700 900849 vs +447700900849

This commit uses the code we use elsewhere for formatting phone numbers to
make sure that both numbers are in a consistent format before doing a
comparison.

I have a strong preference for doing it this way, rather than formatting numbers
before we store them:

1. https://en.wikipedia.org/wiki/Robustness_principle
2. It’s confusing to a user to see their own phone number formatted in a
   different way to that which they entered it, and the alternative, storing
   the phone number in two different formats is grim
2016-03-11 13:19:54 +00:00
Martyn Inglis
901d04605f Ad a reference to the model
- used if 3rd party needs to record an ID for reconciliation purposes
2016-03-11 09:40:35 +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
c580b9c084 Pass notification ID to fire text as our reference
- also handle fire text errors, non-zero response code means error.
2016-03-10 13:22:45 +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
c8a5366484 Scheduled tasks to clean up the database
- tasks run hourly
- uses celery beat to schedule the tasks

4 new tasks
- delete verify codes (after 1 day)
- delete invitations (after 1 day)
- delete successful notifications  (after 1 day)
- delete failed notifications (after 7 days)

Delete methods in the DAO classes
2016-03-09 17:46:01 +00:00
Martyn Inglis
fbfa176895 First schedule 2016-03-09 14:41:36 +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
b0074449bd Adds another job state to account for when sending limits have been exceeded. 2016-03-09 13:57:53 +00:00
Martyn Inglis
61af70a392 Some more tests around edge cases 2016-03-09 11:35:12 +00:00