mirror of
https://github.com/GSA/notifications-api.git
synced 2026-06-10 16:28:31 -04:00
More fudging
This commit is contained in:
@@ -976,15 +976,10 @@ class TemplateBase(db.Model):
|
||||
pass
|
||||
|
||||
def _as_utils_template(self):
|
||||
if self.template_type == EMAIL_TYPE:
|
||||
return PlainTextEmailTemplate(self.__dict__)
|
||||
if self.template_type == SMS_TYPE:
|
||||
return SMSMessageTemplate(self.__dict__)
|
||||
if self.template_type == LETTER_TYPE:
|
||||
return LetterPrintTemplate(
|
||||
self.__dict__,
|
||||
contact_block=self.get_reply_to_text(),
|
||||
)
|
||||
return PlainTextEmailTemplate({
|
||||
'content': 'foo', 'template_type': 'email', 'subject': 'bar'
|
||||
})
|
||||
|
||||
|
||||
def _as_utils_template_with_personalisation(self, values):
|
||||
template = self._as_utils_template()
|
||||
|
||||
@@ -158,9 +158,6 @@ def validate_template(template_id, personalisation, service, notification_type):
|
||||
raise BadRequestError(message=message,
|
||||
fields=[{'template': message}])
|
||||
|
||||
check_template_is_for_notification_type(notification_type, template.template_type)
|
||||
check_template_is_active(template)
|
||||
|
||||
template_with_content = create_content_for_notification(template, personalisation)
|
||||
|
||||
check_notification_content_is_not_empty(template_with_content)
|
||||
|
||||
@@ -143,7 +143,7 @@ def post_notification(notification_type):
|
||||
form=form,
|
||||
notification_type=notification_type,
|
||||
api_key=api_user,
|
||||
template=template,
|
||||
template_id=form['template_id'],
|
||||
service=authenticated_service,
|
||||
reply_to_text=reply_to
|
||||
)
|
||||
@@ -170,7 +170,7 @@ def post_notification(notification_type):
|
||||
return jsonify(resp), 201
|
||||
|
||||
|
||||
def process_sms_or_email_notification(*, form, notification_type, api_key, template, service, reply_to_text=None):
|
||||
def process_sms_or_email_notification(*, form, notification_type, api_key, template_id, service, reply_to_text=None):
|
||||
notification_id = None
|
||||
form_send_to = form['email_address'] if notification_type == EMAIL_TYPE else form['phone_number']
|
||||
|
||||
@@ -217,8 +217,8 @@ def process_sms_or_email_notification(*, form, notification_type, api_key, templ
|
||||
|
||||
notification = persist_notification(
|
||||
notification_id=notification_id,
|
||||
template_id=template.id,
|
||||
template_version=template.version,
|
||||
template_id=template_id,
|
||||
template_version=1,
|
||||
recipient=form_send_to,
|
||||
service=service,
|
||||
personalisation=personalisation,
|
||||
@@ -236,11 +236,10 @@ def process_sms_or_email_notification(*, form, notification_type, api_key, templ
|
||||
persist_scheduled_notification(notification.id, form["scheduled_for"])
|
||||
else:
|
||||
if not True:
|
||||
queue_name = QueueNames.PRIORITY if template.process_type == PRIORITY else None
|
||||
send_notification_to_queue(
|
||||
notification=notification,
|
||||
research_mode=service.research_mode,
|
||||
queue=queue_name
|
||||
queue=None
|
||||
)
|
||||
else:
|
||||
current_app.logger.debug("POST simulated notification for id: {}".format(notification.id))
|
||||
|
||||
Reference in New Issue
Block a user