run_pyl changes

This commit is contained in:
mike cullerton 2023-01-13 11:50:36 -05:00
parent 001db4cd84
commit c3e1dda51e
2 changed files with 16 additions and 11 deletions

View File

@ -78,5 +78,6 @@ SPIFFWORKFLOW_BACKEND_DATABASE_URI = environ.get(
"SPIFFWORKFLOW_BACKEND_DATABASE_URI", default=None "SPIFFWORKFLOW_BACKEND_DATABASE_URI", default=None
) )
SYSTEM_NOTIFICATION_PROCESS_MODEL_MESSAGE_ID = environ.get( SYSTEM_NOTIFICATION_PROCESS_MODEL_MESSAGE_ID = environ.get(
"SYSTEM_NOTIFICATION_PROCESS_MODEL_MESSAGE_ID", default="Message_SystemMessageNotification" "SYSTEM_NOTIFICATION_PROCESS_MODEL_MESSAGE_ID",
default="Message_SystemMessageNotification",
) )

View File

@ -7,6 +7,7 @@ from flask import g
from flask.wrappers import Response from flask.wrappers import Response
from flask_bpmn.api.api_error import ApiError from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db from flask_bpmn.models.db import db
from spiffworkflow_backend.models.message_model import MessageModel from spiffworkflow_backend.models.message_model import MessageModel
from spiffworkflow_backend.models.message_triggerable_process_model import ( from spiffworkflow_backend.models.message_triggerable_process_model import (
MessageTriggerableProcessModel, MessageTriggerableProcessModel,
@ -70,18 +71,21 @@ class ErrorHandlingService:
@staticmethod @staticmethod
def handle_system_notification( def handle_system_notification(
error: Union[ApiError, Exception], error: Union[ApiError, Exception], process_model: ProcessModelInfo
process_model: ProcessModelInfo
) -> Response: ) -> Response:
"""Handle_system_notification.""" """Handle_system_notification."""
recipients = process_model.exception_notification_addresses recipients = process_model.exception_notification_addresses
message_text = f"There was an exception running process {process_model.id}.\nOriginal Error:\n{error.__repr__()}" message_text = (
message_payload = { f"There was an exception running process {process_model.id}.\nOriginal"
'message_text': message_text, f" Error:\n{error.__repr__()}"
'recipients': recipients )
} message_payload = {"message_text": message_text, "recipients": recipients}
message_identifier = current_app.config["SYSTEM_NOTIFICATION_PROCESS_MODEL_MESSAGE_ID"] message_identifier = current_app.config[
message_model = MessageModel.query.filter_by(identifier=message_identifier).first() "SYSTEM_NOTIFICATION_PROCESS_MODEL_MESSAGE_ID"
]
message_model = MessageModel.query.filter_by(
identifier=message_identifier
).first()
message_triggerable_process_model = ( message_triggerable_process_model = (
MessageTriggerableProcessModel.query.filter_by( MessageTriggerableProcessModel.query.filter_by(
message_model_id=message_model.id message_model_id=message_model.id
@ -91,7 +95,7 @@ class ErrorHandlingService:
message_triggerable_process_model, message_triggerable_process_model,
message_identifier, message_identifier,
message_payload, message_payload,
g.user g.user,
) )
return Response( return Response(