Skip to content

Commit

Permalink
Merge pull request #161 from nrempel/bugfix-thread-id-unique
Browse files Browse the repository at this point in the history
Query records on thread_id AND initiator
  • Loading branch information
andrewwhitehead authored Aug 28, 2019
2 parents e0ebae9 + 220f2f9 commit fa3f898
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
23 changes: 19 additions & 4 deletions aries_cloudagent/messaging/credentials/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,10 @@ async def receive_request(self, credential_request_message: CredentialRequest):

credential_exchange_record = await CredentialExchange.retrieve_by_tag_filter(
self.context,
tag_filter={"thread_id": credential_request_message._thread_id},
tag_filter={
"thread_id": credential_request_message._thread_id,
"initiator": "self",
},
)
credential_exchange_record.credential_request = credential_request
credential_exchange_record.state = CredentialExchange.STATE_REQUEST_RECEIVED
Expand Down Expand Up @@ -424,7 +427,11 @@ async def receive_credential(self, credential_message: CredentialIssue):
(
credential_exchange_record
) = await CredentialExchange.retrieve_by_tag_filter(
self.context, tag_filter={"thread_id": credential_message._thread_id}
self.context,
tag_filter={
"thread_id": credential_message._thread_id,
"initiator": "external",
},
)
except StorageNotFoundError:

Expand All @@ -439,7 +446,11 @@ async def receive_credential(self, credential_message: CredentialIssue):
(
credential_exchange_record
) = await CredentialExchange.retrieve_by_tag_filter(
self.context, tag_filter={"thread_id": credential_message._thread.pthid}
self.context,
tag_filter={
"thread_id": credential_message._thread.pthid,
"initiator": "external",
},
)

credential_exchange_record._id = None
Expand Down Expand Up @@ -503,7 +514,11 @@ async def credential_stored(self, credential_stored_message: CredentialStored):
"""

credential_exchange_record = await CredentialExchange.retrieve_by_tag_filter(
self.context, tag_filter={"thread_id": credential_stored_message._thread_id}
self.context,
tag_filter={
"thread_id": credential_stored_message._thread_id,
"initiator": "self",
},
)

credential_exchange_record.state = CredentialExchange.STATE_STORED
Expand Down
4 changes: 3 additions & 1 deletion aries_cloudagent/messaging/presentations/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ async def create_request(
presentation_request=presentation_request,
thread_id=presentation_request_message._thread_id,
)

await presentation_exchange.save(
self.context, reason="Create presentation request"
)
Expand All @@ -105,6 +106,7 @@ async def receive_request(
state=PresentationExchange.STATE_REQUEST_RECEIVED,
presentation_request=json.loads(presentation_request_message.request),
)

await presentation_exchange.save(
self.context, reason="Receive presentation request"
)
Expand Down Expand Up @@ -222,7 +224,7 @@ async def receive_presentation(self, presentation: dict, thread_id: str):
(
presentation_exchange_record
) = await PresentationExchange.retrieve_by_tag_filter(
self.context, tag_filter={"thread_id": thread_id}
self.context, tag_filter={"thread_id": thread_id, "initiator": "self"}
)

presentation_exchange_record.presentation = presentation
Expand Down

0 comments on commit fa3f898

Please sign in to comment.