Skip to content

Commit

Permalink
[CHORE} - Clean up logging of VC connection webhooks (#3215)
Browse files Browse the repository at this point in the history
* handle it all in the webhooks

* return success so acapy does not retry

* log instead of assert

* multiple webhooks for each connection.

* expected 404, true or false are both fine.
  • Loading branch information
Jsyro authored Aug 14, 2024
1 parent f872a53 commit 0f7f576
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
12 changes: 4 additions & 8 deletions services/core-api/app/api/services/traction_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,17 @@ def create_oob_connection_invitation(self, party: Party):
def delete_connection(self, connection_id) -> bool:
delete_resp = requests.delete(
traction_connections + "/" + str(connection_id), headers=self.get_headers())
current_app.logger.info(f"traction_service.delete_connection returned {delete_resp.status_code}")
current_app.logger.info(
f"traction_service.delete_connection returned {delete_resp.status_code}")
return delete_resp.ok

def reject_invitation(self, connection_id) -> bool:
reject_resp = requests.delete(
traction_reject_invitation(connection_id), headers=self.get_headers())
current_app.logger.info(f"traction_service.delete_connection returned {reject_resp.status_code}")
current_app.logger.info(
f"traction_service.delete_connection returned {reject_resp.status_code}")
return reject_resp.ok

def reject_invitation(self, connection_id) -> bool:
reject_resp = requests.delete(
traction_reject_invitation(connection_id), headers=self.get_headers())
assert reject_resp.status_code == 200, f"reject_resp={reject_resp.json()}"
return True

def offer_mines_act_permit_111(self, connection_id, attributes):
# https://github.com/bcgov/bc-vcpedia/blob/main/credentials/bc-mines-act-permit/1.1.1/governance.md#261-schema-definition
payload = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,22 @@ def post(self, topic):
if not vc_conn.connection_id:
# check if party already has a connection
existing_vc_conn = PartyVerifiableCredentialConnection.query.unbound_unsafe(
).filter(PartyVerifiableCredentialConnection.party_guid == vc_conn.party_guid,
PartyVerifiableCredentialConnection.connection_id != webhook_body["connection_id"],
PartyVerifiableCredentialConnection.connection_id != None).first()

).filter(
PartyVerifiableCredentialConnection.party_guid == vc_conn.party_guid,
PartyVerifiableCredentialConnection.connection_id
!= webhook_body["connection_id"],
PartyVerifiableCredentialConnection.connection_id != None).first()

if existing_vc_conn:
current_app.logger.warning(
f"party_guid={vc_conn.party_guid} already has a connection_id={existing_vc_conn.connection_id}"
)
#acapy has started creating a connection delete it so it cannot be completed.
traction_svc = TractionService()

#delete connection record
if not traction_svc.delete_connection(webhook_body["connection_id"]):
current_app.logger.error(
f"error when deleting connection in traction, active aries connnection unusable by CORE, connection_id={webhook_body['connection_id']}"
)
#delete connection record, do not care about result.
traction_svc.delete_connection(webhook_body["connection_id"])

#delete oob invitation record
if not traction_svc.reject_invitation(webhook_body["connection_id"]):
current_app.logger.error(
Expand Down

0 comments on commit 0f7f576

Please sign in to comment.