mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 23:41:17 -05:00
Years ago we started to implement a way to schedule a notification. We hit a problem but we never came up with a good solution and the feature never made it back to the top of the priority list. This PR removes the code for scheduled_for. There will be another PR to drop the scheduled_notifications table and remove the schedule_notifications service permission Unfortunately, I don't think we can remove the `scheduled_for` attribute from the notification.serialized method because out clients might fail if something is missing. For now I have left it in but defaulted the value to None.
71 lines
1.9 KiB
Python
71 lines
1.9 KiB
Python
|
|
|
|
def create_post_sms_response_from_notification(
|
|
notification_id, client_reference, template_id, template_version, service_id,
|
|
content, from_number, url_root
|
|
):
|
|
resp = __create_notification_response(
|
|
notification_id, client_reference, template_id, template_version, service_id, url_root
|
|
)
|
|
resp['content'] = {
|
|
'from_number': from_number,
|
|
'body': content
|
|
}
|
|
return resp
|
|
|
|
|
|
def create_post_email_response_from_notification(
|
|
notification_id,
|
|
client_reference,
|
|
template_id,
|
|
template_version,
|
|
service_id,
|
|
content,
|
|
subject,
|
|
email_from,
|
|
url_root,
|
|
):
|
|
resp = __create_notification_response(
|
|
notification_id, client_reference, template_id, template_version, service_id, url_root
|
|
)
|
|
resp['content'] = {
|
|
"from_email": email_from,
|
|
"body": content,
|
|
"subject": subject
|
|
}
|
|
return resp
|
|
|
|
|
|
def create_post_letter_response_from_notification(
|
|
notification_id, client_reference, template_id, template_version, service_id,
|
|
content, subject, url_root
|
|
):
|
|
resp = __create_notification_response(
|
|
notification_id, client_reference, template_id, template_version, service_id, url_root
|
|
)
|
|
resp['content'] = {
|
|
"body": content,
|
|
"subject": subject
|
|
}
|
|
return resp
|
|
|
|
|
|
def __create_notification_response(
|
|
notification_id, client_reference, template_id, template_version, service_id, url_root
|
|
):
|
|
return {
|
|
"id": notification_id,
|
|
"reference": client_reference,
|
|
"uri": "{}v2/notifications/{}".format(url_root, str(notification_id)),
|
|
'template': {
|
|
"id": template_id,
|
|
"version": template_version,
|
|
"uri": "{}services/{}/templates/{}".format(
|
|
url_root,
|
|
str(service_id),
|
|
str(template_id)
|
|
)
|
|
},
|
|
"scheduled_for": None
|
|
}
|