Skip to content

Commit

Permalink
use connection [ayloads, not oob payloads
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Syrotuck <[email protected]>
  • Loading branch information
Jsyro committed Oct 26, 2023
1 parent 64561c2 commit 069b769
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 5 additions & 2 deletions services/core-api/app/api/parties/party/models/party.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,13 @@ def business_roles_codes(self):

@hybrid_property
def digital_wallet_connection_status(self):
dwi = [i for i in self.digital_wallet_invitations if i.connection_state] # filter empty conn_state
dwi = set([i.connection_state for i in self.digital_wallet_invitations if i.connection_state]) # filter empty conn_state
if dwi:
current_app.logger.warning(dwi)
return dwi.connection_state # active >> invitation
if "active" in dwi:
return "active"
else:
return dwi[0].connection_state # active >> invitation
else:
return None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,18 @@ def post(self, topic):
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={vc_conn.connection_id} with state={new_state}")
current_app.logger.info(f"Updated party_vc_conn connection_id={vc_conn.connection_id} with state={new_state}")
elif topic == OUT_OF_BAND:
invitation_id = webhook_body["invi_msg_id"]
vc_conn = PartyVerifiableCredentialConnection.query.unbound_unsafe().filter_by(invitation_id=invitation_id).first()
assert vc_conn, f"out_of_band.invi_msg_id={invitation_id} not found"
new_state = webhook_body["state"]
if new_state != vc_conn.connection_state:
if new_state == "await-response":
vc_conn.connection_state=new_state
vc_conn.save()
current_app.logger.debug(f"Updated party_vc_conn invitation_id={invitation_id} with state={new_state}")
current_app.logger.info(f"Updated party_vc_conn invitation_id={invitation_id} with state={new_state}")
else:
current_app.logger.debug(f"do not update connection_state with oob_message state")
elif topic == CREDENTIAL_OFFER:
cred_exch_id = webhook_body["credential_exchange_id"]
cred_exch_record = PartyVerifiableCredentialMinesActPermit.query.unbound_unsafe().filter_by(cred_exch_id=cred_exch_id).first()
Expand All @@ -48,7 +50,7 @@ def post(self, topic):
if new_state != cred_exch_record.cred_exch_state:
cred_exch_record.cred_exch_state=new_state
cred_exch_record.save()
current_app.logger.debug(f"Updated cred_exch_record cred_exch_id={cred_exch_id} with state={new_state}")
current_app.logger.info(f"Updated cred_exch_record cred_exch_id={cred_exch_id} with state={new_state}")

else:
current_app.logger.info(f"unknown topic '{topic}'")

0 comments on commit 069b769

Please sign in to comment.