Merge branch 'master' into inbound-sms

Conflicts:
	app/notifications/receive_notifications.py
	tests/app/notifications/test_receive_notification.py
This commit is contained in:
Martyn Inglis
2017-06-01 15:56:33 +01:00
28 changed files with 876 additions and 178 deletions

View File

@@ -1,4 +1,5 @@
from urllib.parse import unquote
from flask import jsonify
from flask import Blueprint, current_app, request
from notifications_utils.recipients import normalise_phone_number
@@ -7,10 +8,7 @@ from app import statsd_client
from app.dao.services_dao import dao_fetch_services_by_sms_sender
from app.dao.inbound_sms_dao import dao_create_inbound_sms
from app.models import InboundSms
from app.errors import (
register_errors,
InvalidRequest
)
from app.errors import register_errors
receive_notifications_blueprint = Blueprint('receive_notifications', __name__)
register_errors(receive_notifications_blueprint)
@@ -67,3 +65,13 @@ def create_inbound_sms_object(service, json):
)
dao_create_inbound_sms(inbound)
return inbound
@receive_notifications_blueprint.route('/notifications/sms/receive/firetext', methods=['POST'])
def receive_firetext_sms():
post_data = request.form
current_app.logger.info("Received Firetext notification form data: {}".format(post_data))
return jsonify({
"status": "ok"
}), 200

View File

@@ -6,7 +6,7 @@ from notifications_utils.recipients import (
)
from app.dao import services_dao
from app.models import KEY_TYPE_TEST, KEY_TYPE_TEAM, SMS_TYPE
from app.models import KEY_TYPE_TEST, KEY_TYPE_TEAM, SMS_TYPE, SCHEDULE_NOTIFICATIONS
from app.service.utils import service_allowed_to_send_to
from app.v2.errors import TooManyRequestsError, BadRequestError, RateLimitError
from app import redis_store
@@ -92,6 +92,7 @@ def check_sms_content_char_count(content_count):
raise BadRequestError(message=message)
def service_can_schedule_notification(service):
# TODO: implement once the service permission works.
raise BadRequestError(message="Your service must be invited to schedule notifications via the API.")
def service_can_schedule_notification(service, scheduled_for):
if scheduled_for:
if SCHEDULE_NOTIFICATIONS not in [p.permission for p in service.permissions]:
raise BadRequestError(message="Cannot schedule notifications (this feature is invite-only)")