mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 15:31:15 -05:00
Send Email via the API
- uses the new subject/email from fields present on the templates / service tables - brings the send email api call into line with the sms one. - same fields (to/template_id) - same rules regarding restricted services - wired in as a task into celery Requires - new celery queue - new env property (NOTIFY_EMAIL_DOMAIN)
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import re
|
||||
from datetime import datetime
|
||||
|
||||
from flask import (
|
||||
@@ -30,6 +29,7 @@ from app.schemas import (
|
||||
service_schema,
|
||||
api_keys_schema
|
||||
)
|
||||
from app import email_safe
|
||||
|
||||
from flask import Blueprint
|
||||
|
||||
@@ -76,7 +76,7 @@ def create_service():
|
||||
|
||||
data.pop('user_id', None)
|
||||
if 'name' in data:
|
||||
data['email_from'] = _email_safe(data.get('name', None))
|
||||
data['email_from'] = email_safe(data.get('name', None))
|
||||
|
||||
valid_service, errors = service_schema.load(request.get_json())
|
||||
|
||||
@@ -87,13 +87,6 @@ def create_service():
|
||||
return jsonify(data=service_schema.dump(valid_service).data), 201
|
||||
|
||||
|
||||
def _email_safe(string):
|
||||
return "".join([
|
||||
character.lower() if character.isalnum() or character == "." else ""
|
||||
for character in re.sub("\s+", ".", string.strip())
|
||||
])
|
||||
|
||||
|
||||
@service.route('/<service_id>', methods=['POST'])
|
||||
def update_service(service_id):
|
||||
fetched_service = dao_fetch_service_by_id(service_id)
|
||||
|
||||
Reference in New Issue
Block a user