Commit Graph

34 Commits

Author SHA1 Message Date
Leo Hemsted
f3d129b0d8 fix 500s when inbound msgs sent from alphanumerics rather than normal phone numbers 2017-11-23 15:22:18 +00:00
Alexey Bezhan
3bcde5437b Add tests for aborting unauthenticated requests
Tests are disabled until aborts are switched on
2017-11-22 09:54:42 +00:00
Rebecca Law
e3f9dab884 Merge branch 'master' into remove-initial-update-sms-sender 2017-11-14 16:27:10 +00:00
Chris Hill-Scott
4761d852e9 Fix escaping in inbound text messages from MMG
One of our providers gives us messages with special characters escaped,
ie a newline comes through as `\n`, not a literal newline. We shouldn’t
be showing these backslashes to any of our users. We also have examples
of real inbound messages containing `👍` and `’`, so we should continue
to display these properly.

It’s a bit tricky, because the strings we get from this provider are a
mixture of escape sequences (eg `\n`) and unicode characters (eg `😨`).
So we have to first convert the unicode character `😨` into an escape
sequence, `\U0001f628` in this example. We do this by encoding with
the `raw_unicode_escape` codec:

> Latin-1 encoding with \uXXXX and \UXXXXXXXX for other code points.
> Existing backslashes are not escaped in any way. It is used in the
> Python pickle protocol.

– https://docs.python.org/3/library/codecs.html#text-encodings

Then we turn this back into a string using the `unicode_escape` codec,
which transforms all escape sequences into their literal representations
(eg `\U0001f628` becomes `😨` and `\n` becomes a newline).
2017-11-08 13:32:30 +00:00
Rebecca Law
0054361044 Refactor the sms sender code to remove any unused methods.
Refactor tests/db/create_service() to behave more like the real world.
Created new create_service_with_inbound_number and create_service_with_defined_sms_sender() test/db methods.
2017-11-07 14:26:18 +00:00
venusbb
6a7013fa7a Enable Inbound sms IP blocking 2017-09-26 10:59:09 +01:00
Ken Tsang
d99ab329eb Refactored code to use inbound_number.number
- Removed filter on sms_sender for `dao_fetch_services_by_inbound_number`
2017-08-23 14:14:32 +01:00
Leo Hemsted
ae683cad6e Merge pull request #1192 from alphagov/deps
update dependencies
2017-08-22 15:39:49 +01:00
Leo Hemsted
c36e50bef1 update dependencies 2017-08-18 17:02:31 +01:00
Ken Tsang
3a70d63a7c Test for inbound_number when no inbound_sms permissions 2017-08-16 16:28:56 +01:00
Ken Tsang
c36423aac6 Refactor code for dao_fetch_servies_by_sms_sender to use inbound_numbers
This will need to be refactored after the deployment of api and admin and after the update script for existing services using inbound numbers has been executed.
2017-08-16 12:51:31 +01:00
Ken Tsang
667ee57a35 Refactor code to use inbound_numbers if set 2017-08-16 12:50:44 +01:00
Ken Tsang
8b04039a5a Refactor to abstract inbound_sms perms check 2017-07-06 12:31:02 +01:00
Ken Tsang
3372fe6b18 Refactored test 2017-07-06 12:31:01 +01:00
Ken Tsang
5efe4d59ec Improved test to include check on log 2017-07-06 12:31:01 +01:00
Ken Tsang
f028dab252 Removed firetext params 2017-07-06 12:31:01 +01:00
Ken Tsang
e96a67c59b Firetext tests 2017-07-06 12:31:01 +01:00
Ken Tsang
5a82fe0a70 Add inbound sms permission check 2017-07-06 12:31:01 +01:00
Rebecca Law
c608f5997b New task to send the inbound sms to the service.
If the service has not set the url then nothing happens.
If the request to the service url returns with 500 or greater the task is retries.
The task is created when the SMS provider post the inbound SMS.
2017-06-20 17:13:40 +01:00
Martyn Inglis
29455b6d3b Strip leading 44 from inbound SMS numbers to normalise to how we store things. 2017-06-06 11:50:30 +01:00
Martyn Inglis
b296e736f2 Reorder the migrations. 2017-06-05 11:51:30 +01:00
Martyn Inglis
f15d235d1e Merge branch 'master' into firetext-inbound-sms 2017-06-05 11:33:53 +01:00
Martyn Inglis
012f8d2675 Adds provider onto the inbound sms table so we know where this came from. 2017-06-02 16:37:57 +01:00
Martyn Inglis
3e1de2e901 Capture the fire text callbacks.
Parse the form data, and stop the message
2017-06-02 15:58:36 +01:00
Leo Hemsted
bf18b179b0 ensure the user_number in inbound sms is international
rather than using the `normalise_phone_number` function, use the
`validate_and_format_phone_number` function - this will also convert
all numbers to international format, which means we won't need to
worry about whether the user enters internaional or UK phone numbers
when searching
2017-06-02 15:20:18 +01:00
Leo Hemsted
d9bdacb5cd parse datetimes from mmg inbound sms
the DateRecieved field from MMG comes in with +s instead of spaces,
and uriencoded (the same as how they format their messages)
Make sure we decode this, and then convert to a UTC timestamp
2017-06-02 10:14:01 +01:00
Leo Hemsted
dba4e2ad89 mmg spell received incorrectly, lets use that 2017-06-01 17:27:09 +01:00
Martyn Inglis
c57e2a6894 Merge branch 'master' into inbound-sms
Conflicts:
	app/notifications/receive_notifications.py
	tests/app/notifications/test_receive_notification.py
2017-06-01 15:56:33 +01:00
Leo Hemsted
dd9fd6cf92 still return RECEIVED even if we couldn't find a matching service
mmg don't need to retry that message or anything. just log it.
2017-06-01 13:13:51 +01:00
Martyn Inglis
a7fd624db5 Added simple logging endpoint for fire text inbound SMS calls
- logs post data
- OK to log all as not currently in use so no real user data expected.
2017-06-01 08:21:18 +01:00
Martyn Inglis
3c416d3631 Simple end point for fire text inbound SMS callbacks. 2017-05-31 16:15:25 +01:00
Leo Hemsted
ef799d0515 add sad path tests for inbound sms 2017-05-30 11:14:18 +01:00
Leo Hemsted
4a85818c34 add inbound sms table 2017-05-30 10:47:01 +01:00
Rebecca Law
77f520acba Created an endpoint to test how the incoming messages from MMG will work.
So this just prints the response to logs, removing the phone number first. Then returns the requested RECEIVED.
2017-03-06 11:58:49 +00:00