diff --git a/aries_cloudagent/connections/models/conn_record.py b/aries_cloudagent/connections/models/conn_record.py index da556ed4ab..116a91568f 100644 --- a/aries_cloudagent/connections/models/conn_record.py +++ b/aries_cloudagent/connections/models/conn_record.py @@ -345,10 +345,7 @@ async def find_existing_connection( session: The active profile session their_public_did: Inviter public DID (or did:peer) """ - if their_public_did.startswith("did:peer"): - tag_filter = {"their_did": their_public_did} - else: - tag_filter = {"their_public_did": their_public_did} + tag_filter = {"their_public_did": their_public_did} conn_records = await cls.query( session, tag_filter=tag_filter, diff --git a/aries_cloudagent/protocols/out_of_band/v1_0/manager.py b/aries_cloudagent/protocols/out_of_band/v1_0/manager.py index b55e492615..b5e011dcab 100644 --- a/aries_cloudagent/protocols/out_of_band/v1_0/manager.py +++ b/aries_cloudagent/protocols/out_of_band/v1_0/manager.py @@ -705,14 +705,16 @@ async def receive_invitation( if ( public_did is not None and use_existing_connection ): # invite has public DID: seek existing connection - LOGGER.debug( - "Trying to find existing connection for oob invitation with " - f"did {public_did}" - ) if public_did.startswith("did:peer:4"): search_public_did = self.long_did_peer_to_short(public_did) else: search_public_did = public_did + + LOGGER.debug( + "Trying to find existing connection for oob invitation with " + f"did {search_public_did}" + ) + async with self._profile.session() as session: conn_rec = await ConnRecord.find_existing_connection( session=session, their_public_did=search_public_did @@ -1046,7 +1048,11 @@ async def _perform_handshake( # in an out-of-band message (RFC 0434). # OR did:peer:2 or did:peer:4. - if not service.startswith("did:peer"): + if service.startswith("did:peer"): + public_did = service + if public_did.startswith("did:peer:4"): + public_did = self.long_did_peer_to_short(public_did) + else: public_did = service.split(":")[-1] # TODO: resolve_invitation should resolve key_info objects