Commit Graph

68 Commits

Author SHA1 Message Date
Leo Hemsted
0a052d45a8 actually bump version
missed a number last time 😧
2016-08-22 14:40:02 +01:00
Leo Hemsted
d5ec73bc8a update utils version 2016-08-22 13:38:45 +01:00
Martyn Inglis
99a8a4f7ce Bumped utils version 2016-08-08 12:29:01 +01:00
Martyn Inglis
365019461b Updated utils version 2016-08-05 13:53:46 +01:00
Chris Hill-Scott
482a435e66 Fix newlines in HTML emails
Implements:
- [ ] https://github.com/alphagov/notifications-utils/pull/60
2016-08-01 14:23:10 +01:00
Chris Hill-Scott
d8ab82b139 Fix Markdown/HTML email oddities
Depends on:
- [ ] https://github.com/alphagov/notifications-utils/pull/59
2016-08-01 11:16:18 +01:00
Chris Hill-Scott
68fd4947cb Update utils for Markdown parsing + subbranding
Markdown parsing (will be active but isn’t documented):
- [x] https://github.com/alphagov/notifications-utils/pull/54

Email sub branding (not used yet):
- [x] https://github.com/alphagov/notifications-utils/pull/55

Required modification to the email preview endpoint to make sure that
it only included the message and not any HTML.
2016-07-22 11:09:23 +01:00
Chris Hill-Scott
ba1c1fd07a Upgrade bleach to fix dodgy html5lib version
Bleach 1.4.2 installs html5lib version 0.999 or greater.

This was fine, until version 0.999999999 (nine nines was released, which
doesn’t work.

Bleach 1.4.3 pins html5lib to 0.9999999 (seven nines), which stops the
bad version getting installed.
2016-07-15 13:39:23 +01:00
Chris Hill-Scott
a4a934f6ba Add formatting of emails, conditional placeholders
Implements and depends on:
- [x] https://github.com/alphagov/notifications-utils/pull/45
- [x] https://github.com/alphagov/notifications-utils/pull/47
- [x] https://github.com/alphagov/notifications-utils/pull/48
- [x] https://github.com/alphagov/notifications-utils/pull/50
- [ ] https://github.com/alphagov/notifications-utils/pull/51
- [ ] https://github.com/alphagov/notifications-utils/pull/52

Should be deployed ahead of the admin side of these features, which
is in: https://github.com/alphagov/notifications-admin/pull/781
2016-07-13 15:10:54 +01:00
Chris Hill-Scott
a8a556d02a Use PassThrough renderer
Implements and depends on:
- [ ] https://github.com/alphagov/notifications-utils/pull/49
2016-07-07 22:48:07 +01:00
Chris Hill-Scott
824085ead8 Bring in changes to template and CSV processing
Functional changes:
- adds the blue bar

Performance changes
- faster CSV processing

Depends on:

- [ ] https://github.com/alphagov/notifications-utils/pull/47
- [ ] https://github.com/alphagov/notifications-utils/pull/48

Also brings in some breaking changes, which do not affect utils (apart
from a weird import).
2016-07-07 15:44:30 +01:00
Chris Hill-Scott
5e0033e36d Merge pull request #488 from alphagov/email-breathing-room
Add breathing room around GOV.UK logo in emails
2016-07-01 13:50:08 +01:00
Chris Hill-Scott
0358bdfe05 Add breathing room around GOV.UK logo in emails
Implements and depends on:

- [ ] https://github.com/alphagov/notifications-utils/pull/44
2016-06-30 15:27:21 +01:00
Chris Hill-Scott
7c3d25a87a Publish a Swagger specification
Adds a new endpoint (`/spec`) which returns a the specification of the
API in Swagger-formatted JSON.

This means we will have something to point frontends at, so we can
evaluate which ones we like.

Right now it’s all hand-defined. If we were consistent about our use of
Marshmallow we could generated the spec from the Marshmallow schemas.
2016-06-29 12:07:32 +01:00
Chris Hill-Scott
03192b81c5 Make URLs appear as links in email clients
Implements: https://github.com/alphagov/notifications-utils/pull/42
2016-06-07 16:21:27 +01:00
Chris Hill-Scott
34740c5827 Bump utils to latest version
This commit doesn’t introduce any new functionality, just keeps things
from getting too far behind.

This is a breaking change in utils, see:
4683922d30

None of these methods are used by the API, so no API code needs to
change, cf:

https://github.com/alphagov/notifications-api/search?utf8=%E2%9C%93&q=rows_with_errors&type=Code
https://github.com/alphagov/notifications-api/search?utf8=%E2%9C%93&q=has_errors&type=Code
https://github.com/alphagov/notifications-api/search?utf8=%E2%9C%93&q=annotated_rows&type=Code
https://github.com/alphagov/notifications-api/search?utf8=%E2%9C%93&q=annotated_rows_with_errors&type=Code
2016-06-06 11:05:32 +01:00
Nicholas Staples
0fe0c1d2b4 Added job row number to the notification for csv jobs. All tests passing. 2016-05-19 10:46:03 +01:00
Chris Hill-Scott
0cd01f831c Bump utils version
Includes:

- https://github.com/alphagov/notifications-utils/pull/33
  Ensure email header is full width
- https://github.com/alphagov/notifications-utils/pull/32
  Handle CSV files with blank column headers
2016-05-17 13:24:08 +01:00
Martyn Inglis
3f7559b286 Added statsd integration into the API
- new client for statsd, follows conventions used elsewhere for configuration
- client wraps underlying library so we can use a config property to send/not send statsd

Added statsd metrics for:
- count of API successful calls SMS/Email
- count of successful task execution for SMS/Email
- count of errors from Client libraries
- timing of API calls to third party clients
- timing of how long messages live on the SQS queue
2016-05-13 17:15:39 +01:00
Martyn Inglis
9fb3569291 bumped request version 2016-05-12 16:37:01 +01:00
Rebecca Law
b53fdf1f3f Update python client to version 1.0.0.
This version of the client removed the request method, path and body from the encode and decode methods.
The biggest changes here is to the unit tests.
2016-05-04 16:08:23 +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
Nicholas Staples
f71dbe9c0f Message limit added and all tests passing. 2016-04-29 10:36:59 +01:00
Chris Hill-Scott
a6f78ecdbd Merge pull request #225 from alphagov/unlink-govuk
Stop GOV.UK becoming a link in email clients
2016-04-15 13:34:06 +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
Rebecca Law
282a62e636 Use the new version of the notifications-python-client. This version no longer adds the req and pay to the claims of the jwt.
The change is backward compatible so an older client that sends a jwt with the extra claims will pass authentication.
Once all the clients have been updated to not include the extra claims some updates to exclude them from the method signatures will happen as well.
2016-04-14 18:12:33 +01:00
Nicholas Staples
1b76646170 Working placeholders in subject with upgraded notifications-utils.
Fix test.
2016-04-13 15:53:27 +01:00
Chris Hill-Scott
98c92fa04e Use version of crown logo hosted by admin app
Implements and depends on:
https://github.com/alphagov/notifications-utils/pull/19

Depends on this admin app deploy:
https://github.com/alphagov/notifications-admin/pull/410
2016-04-07 10:01:05 +01:00
Chris Hill-Scott
7f7c5bc9d3 Fix bug with whitelist
Implements https://github.com/alphagov/notifications-utils/pull/17
2016-04-05 12:00:31 +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
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
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
Chris Hill-Scott
589b4de5f9 Accept CSV files with additional columns
Currently when the Celery task processes a CSV it will call the API with the
values for all the non-recipient columns in the `personalisation` field. This
means that those API calls would fail, even though the CSV has been processed
‘successfully’.

This was not being caught by the tests, so this commit adds extra tests to check
what data the task is passing to the API call.

It then updates utils to version 2.0.1 which brings in this fix:
https://github.com/alphagov/notifications-utils/pull/10
2016-03-09 09:52:39 +00:00
Chris Hill-Scott
7cb8450839 Use RecipientCSV from utils for processing CSVs
See https://github.com/alphagov/notifications-utils/pull/9 for details of the
changes.
2016-03-08 09:43:48 +00:00
Chris Hill-Scott
b3f4e40421 Strip HTML from template content
Templates are created in the admin app and persisted in the API.

They are consumed:
- in the admin app, by requesting them from the API
- in the API, by loading them from the database

There are two potential places where unescaped HTML could be sent to a user:
- when the admin app is previewing a template (it has to render the template as
  markup in order to show the placeholders)
- in the body of an email

For all consumers to have confidence that the templates are safe, it makes sense
to santitise them at the point of creation (and modification). This also avoids
any performance issues that could come from doing it at the point of requesting
a template.

In the future they could be created by a direct API call, bypassing the admin
app. Therefore it makes sense for the API to sanitise them.

The commit sanitises templates using a Mozilla’s Bleach library[1]. It is
configured to get the text content of the template, minus any HTML tags. It is
not using a regex because[2].

1. https://github.com/mozilla/bleach
2. http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454
2016-03-04 22:07:10 +00:00
NIcholas Staples
62f66329a9 Merge pull request #117 from alphagov/time-3rd-party-calls
Add logging around 3rd party delivery calls
2016-03-02 11:27:00 +00:00
Martyn Inglis
35b7b884f8 Add logging around 3rd party delivery calls
- time SES, Twilio, fire text calls
- use monotonic for accuracy
2016-03-02 09:33:20 +00:00
Chris Hill-Scott
d6f7c7d1c9 Replace placeholders before sending a message
This commit replaces placeholders in a template with the user’s data, using
the Template class from utils
(https://github.com/alphagov/notifications-utils/tree/master/utils#template)

It also extracts the personalisation data from the CSV, taking account of the
different column headings that SMS and email CSVs will have.

At the point of creating the task to send an individual messages, validation of
the placeholders matching the template is assumed to have been done either:
- in processing the CSV in the admin app
- in the endpoint for the API call

No exceptions should be raised at this point.
2016-03-02 08:59:34 +00:00
Rebecca Law
df278a8e6e Email invitation to an invited user.
New celery task to send the email.
2016-02-29 13:21:12 +00:00
Martyn Inglis
36eee56f17 Adding boto for python2 as Celery seems to need it. 2016-02-17 14:03:40 +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
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
Martyn Inglis
a1be4e3ca5 Updated python client verion 2016-02-10 12:33:54 +00:00
Martyn Inglis
d38ba0d36a bumped client version 2016-02-09 18:48:02 +00:00
Martyn Inglis
fb41acdac9 Celery tests 2016-02-09 13:31:45 +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
Rebecca Law
42a4c8b0b1 Add sms notifications from a service to a queue. 2016-01-27 17:42:05 +00:00
Nicholas Staples
a9fe6ad469 Working code and tests. 2016-01-22 14:43:30 +00:00
Nicholas Staples
6b035cd324 All tests working, second time around. 2016-01-21 17:29:24 +00:00
Nicholas Staples
50c3f3dc55 Bump of requirement version. 2016-01-20 14:28:17 +00:00