Skip to content

Commit

Permalink
[FIX] - Two topics of webhooks are used for connections (#2749)
Browse files Browse the repository at this point in the history
* convert to TS and correct condition

* commo folder sync

* log payload, not entire request

* do not include empty string connection_state when checking status

* two webhook topics to listen for...

the out of band message is completed, then the connection process finishes after.
Signed-off-by: Jason Syrotuck <[email protected]>

* fix conflict

Signed-off-by: Jason Syrotuck <[email protected]>

---------

Signed-off-by: Jason Syrotuck <[email protected]>
  • Loading branch information
Jsyro authored Oct 26, 2023
1 parent 33f2050 commit 85020a8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ def find_by_party_guid(cls, party_guid) -> "PartyVerifiableCredentialConnection"

@classmethod
def find_by_invitation_id(cls, invitation_id) -> "PartyVerifiableCredentialConnection":
return cls.query.filter_by(invitation_id=invitation_id).one_or_none()
return cls.query.filter_by(invitation_id=invitation_id).one_or_none()

@classmethod
def find_by_connection_id(cls, connection_id) -> "PartyVerifiableCredentialConnection":
return cls.query.filter_by(connection_id=connection_id).one_or_none()
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,23 @@
PRESENT_PROOF = "present_proof"
CONNECTIONS = "connections"
CREDENTIAL_OFFER = "issue_credential"
OUT_OF_BAND = "out_of_band"

class VerifiableCredentialWebhookResource(Resource, UserMixin):
@api.doc(description='Endpoint to recieve webhooks from Traction.', params={})
def post(self, topic):
current_app.logger.warning(f"TRACTION WEBHOOK: {request.args}")
current_app.logger.warning(f"TRACTION WEBHOOK <topic={topic}>: {request.args}")
if topic == CONNECTIONS:
current_app.logger.warning(f"{request.args.keys()}")
connection_id = request.args['connection_id']
vc_conn = PartyVerifiableCredentialConnection.query.unbound_unsafe().filter_by(connection_id=connection_id).first()
assert vc_conn, f"{connection_id} not found"
new_state = request.args["state"]
if new_state != vc_conn.connection_state:
vc_conn.connection_state=new_state
vc_conn.save()
current_app.logger.debug(f"Updated party_vc_conn connection_id={connection_id} with state={new_state}")
if topic == OUT_OF_BAND:
invitation_id = request.args.get("invi_msg_id")
vc_conn = PartyVerifiableCredentialConnection.query.unbound_unsafe().filter_by(invitation_id=invitation_id).first()
assert vc_conn, f"{invitation_id} not found"
Expand All @@ -38,4 +49,4 @@ def post(self, topic):
current_app.logger.debug(f"Updated cred_exch_record cred_exch_id={cred_exch_id} with state={new_state}")

else:
current_app.logger.info(f"unknown topic={topic} received, payload ={request}")
current_app.logger.info(f"unknown topic={topic}")

0 comments on commit 85020a8

Please sign in to comment.