mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-18 05:28:49 -04:00
add send_notification file for handling sending one off messages
currently, they're made by creating a one-line job, but we want to reduce task/csv file noise so we're moving them to persist in the same vein as API usage. However, we can't just call through to that since there are some differences: * no api keys * tighter control over API format * no scheduling * no client references etc. So, re-using as much of the v2 validation stuff as possible, I've created this file that just does basic validation, and then calls through to persist_notification and schedules a task. Woo.
This commit is contained in:
@@ -61,6 +61,7 @@ from app.service import statistics
|
||||
from app.service.service_inbound_api_schema import service_inbound_api, update_service_inbound_api_schema
|
||||
from app.service.utils import get_whitelist_objects
|
||||
from app.service.sender import send_notification_to_service_users
|
||||
from app.service.send_notification import send_one_off_notification
|
||||
from app.schemas import (
|
||||
service_schema,
|
||||
api_key_schema,
|
||||
@@ -591,3 +592,9 @@ def handle_sql_errror(e):
|
||||
return jsonify(result='error', message="No result found"), 404
|
||||
else:
|
||||
raise e
|
||||
|
||||
|
||||
@service_blueprint.route('/<uuid:service_id>/send-notification', methods=['POST'])
|
||||
def post_notification(service_id):
|
||||
resp = send_one_off_notification(service_id, request.get_json())
|
||||
return jsonify(resp), 201
|
||||
|
||||
Reference in New Issue
Block a user