From 32042e8487cd42ea8197945c7268e19d25a075aa Mon Sep 17 00:00:00 2001 From: "Colton Wolkins (Indicio work address)" Date: Fri, 5 Jan 2024 16:09:00 -0700 Subject: [PATCH] fix: skip forwarding if unnecessary Signed-off-by: Colton Wolkins (Indicio work address) --- didcomm_messaging/routing.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/didcomm_messaging/routing.py b/didcomm_messaging/routing.py index 4388dd7..d54f00c 100644 --- a/didcomm_messaging/routing.py +++ b/didcomm_messaging/routing.py @@ -103,6 +103,10 @@ async def prepare_forward( if not chain[-1]["service"]: raise RoutingServiceError(f"No DIDCommV2 service endpoint found for {to}") + # If we didn't find any services to forward to, just bail + if len(chain) == 1: + return (encoded_message, chain[-1]["service"]) + # Grab our target to pack the initial message to, then pack the message # for the DID target final_destination = chain.pop(0)