From 4ca6e3f27660e9140438e0e2de042208e434223d Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 27 Feb 2023 14:01:21 -0500 Subject: [PATCH] Needed an additional check for empty correlation keys - which on a RECEIVE message, should always match anything. When finding messages to match a send, assure they are RECIEVE messages. Fix some of the json output for messages sent to the front end --- src/spiffworkflow_backend/models/message_instance.py | 5 +++++ src/spiffworkflow_backend/services/message_service.py | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/spiffworkflow_backend/models/message_instance.py b/src/spiffworkflow_backend/models/message_instance.py index 6443f149..3c278b92 100644 --- a/src/spiffworkflow_backend/models/message_instance.py +++ b/src/spiffworkflow_backend/models/message_instance.py @@ -100,6 +100,11 @@ class MessageInstanceModel(SpiffworkflowBaseDBModel): # We know we have a match, and we can just return if we don't have to figure out the key return True + if self.correlation_keys == {}: + # Then there is nothing more to match on -- we accept any message with the given name. + return True + + # Loop over the receives' correlation keys - if any of the keys fully match, then we match. for expected_values in self.correlation_keys.values(): if self.payload_matches_expected_values( diff --git a/src/spiffworkflow_backend/services/message_service.py b/src/spiffworkflow_backend/services/message_service.py index 0d0060bc..ddd4f497 100644 --- a/src/spiffworkflow_backend/services/message_service.py +++ b/src/spiffworkflow_backend/services/message_service.py @@ -1,6 +1,6 @@ """Message_service.""" from spiffworkflow_backend.models.db import db -from spiffworkflow_backend.models.message_instance import MessageInstanceModel +from spiffworkflow_backend.models.message_instance import MessageInstanceModel, MessageTypes from spiffworkflow_backend.models.message_instance import MessageStatuses from spiffworkflow_backend.models.message_triggerable_process_model import ( MessageTriggerableProcessModel, @@ -42,7 +42,8 @@ class MessageService: # Find available messages that might match available_receive_messages = MessageInstanceModel.query.filter_by( - name=message_instance_send.name, status=MessageStatuses.ready.value + name=message_instance_send.name, status=MessageStatuses.ready.value, + message_type=MessageTypes.receive.value ).all() message_instance_receive: MessageInstanceModel | None = None try: