mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 22:42:28 -05:00
Task is the same whether job based or not
- use notification to build action - notification has job - based in encrypted blob
This commit is contained in:
@@ -9,7 +9,7 @@ from sqlalchemy.exc import SQLAlchemyError
|
||||
|
||||
|
||||
@notify_celery.task(name="send-sms")
|
||||
def send_sms(service_id, notification_id, encrypted_notification, job_id=None):
|
||||
def send_sms(service_id, notification_id, encrypted_notification):
|
||||
notification = encryption.decrypt(encrypted_notification)
|
||||
template = get_model_templates(notification['template'])
|
||||
|
||||
@@ -19,7 +19,7 @@ def send_sms(service_id, notification_id, encrypted_notification, job_id=None):
|
||||
template_id=notification['template'],
|
||||
to=notification['to'],
|
||||
service_id=service_id,
|
||||
job_id=job_id,
|
||||
job_id=notification.get('job', None),
|
||||
status='sent'
|
||||
)
|
||||
save_notification(notification_db_object)
|
||||
|
||||
@@ -41,12 +41,12 @@ def get_job_for_service(service_id, job_id=None):
|
||||
if job_id:
|
||||
try:
|
||||
job = get_job(service_id, job_id)
|
||||
if not job:
|
||||
return jsonify(result="error", message="Job not found"), 404
|
||||
data, errors = job_schema.dump(job)
|
||||
return jsonify(data=data)
|
||||
except DataError:
|
||||
return jsonify(result="error", message="Invalid job id"), 400
|
||||
except NoResultFound:
|
||||
return jsonify(result="error", message="Job not found"), 404
|
||||
else:
|
||||
jobs = get_jobs_by_service(service_id)
|
||||
data, errors = jobs_schema.dump(jobs)
|
||||
|
||||
@@ -105,8 +105,7 @@ def create_sms_for_service(service_id):
|
||||
send_sms.apply_async((
|
||||
api_user['client'],
|
||||
notification_id,
|
||||
encryption.encrypt(notification),
|
||||
job_id),
|
||||
encryption.encrypt(notification)),
|
||||
queue='sms')
|
||||
return jsonify({'notification_id': notification_id}), 201
|
||||
|
||||
|
||||
Reference in New Issue
Block a user