From d321bf8056122ab41cc1658fa2aee63002ea4be3 Mon Sep 17 00:00:00 2001 From: Jason Sherman Date: Thu, 23 Jun 2022 16:24:00 -0700 Subject: [PATCH] Remove all unused event/notification code. Signed-off-by: Jason Sherman --- services/showcase/api/services/webhooks.py | 18 ------- services/showcase/frontend/src/main.js | 4 -- .../src/store/modules/notifications.js | 5 -- .../traction/api/endpoints/models/webhooks.py | 2 - .../api/services/IssueCredentialWorkflow.py | 10 ---- .../api/services/PresentCredentialWorkflow.py | 15 ------ .../api/services/tenant_workflow_notifier.py | 52 ------------------- 7 files changed, 106 deletions(-) diff --git a/services/showcase/api/services/webhooks.py b/services/showcase/api/services/webhooks.py index 319f05399..8517177d0 100644 --- a/services/showcase/api/services/webhooks.py +++ b/services/showcase/api/services/webhooks.py @@ -15,7 +15,6 @@ OutOfBandRepository, ) from api.db.repositories.job_applicant import ApplicantRepository -from api.services.websockets import notifier from api.services import traction logger = logging.getLogger(__name__) @@ -216,18 +215,6 @@ async def handle_credential_revoked(lob: Lob, payload: dict, db: AsyncSession): async def handle_webhook(lob: Lob, topic: str, payload: dict, db: AsyncSession): logger.info(f"handle_webhook(lob = {lob.name}, topic = {topic})") - # TODO - make proper notifications to FE that are useful... - await notifier.push( - { - "topic": topic, - "payload": payload, - "lob": { - "sandbox_id": str(lob.sandbox_id), - "id": str(lob.id), - "name": lob.name, - }, - } - ) # topic = "connections" is the acapy event, ignore that one if "connection" == topic: return await handle_connections(lob, payload, db) @@ -235,11 +222,6 @@ async def handle_webhook(lob: Lob, topic: str, payload: dict, db: AsyncSession): return await handle_issuer(lob, payload, db) elif "schema" == topic: return await handle_schema(lob, payload, db) - # topic = "issue_credential" is the acapy event, ignore that one - elif "issue_cred" == topic: - return await handle_issue_credential(lob, payload, db) - elif "present_req" == topic: - return await handle_presentation_request(lob, payload, db) elif "present_proof" == topic: return await handle_present_proof(lob, payload, db) elif "issuer_cred_rev" == topic: diff --git a/services/showcase/frontend/src/main.js b/services/showcase/frontend/src/main.js index 7aa0bcd5f..915ce1858 100644 --- a/services/showcase/frontend/src/main.js +++ b/services/showcase/frontend/src/main.js @@ -35,10 +35,6 @@ Vue.use(VueNativeSock, socketApi, { } let message = event; let target = eventName.toUpperCase(); - if (target === 'SOCKET_ONMESSAGE' && this.format === 'json' && event.data) { - message = JSON.parse(event.data); - target = 'notifications/onNotification'; - } this.store.commit(target, message); }, }); diff --git a/services/showcase/frontend/src/store/modules/notifications.js b/services/showcase/frontend/src/store/modules/notifications.js index aa8932f74..0566afac7 100644 --- a/services/showcase/frontend/src/store/modules/notifications.js +++ b/services/showcase/frontend/src/store/modules/notifications.js @@ -21,11 +21,6 @@ export default { state.notifications = state.notifications.filter( notification => notification.id !== notificationToRemove.id ); - }, - onNotification(state, notification) { - console.log('onNotification()'); // eslint-disable-line no-console - console.log(notification); // eslint-disable-line no-console - // TODO: this is where the notifications from the ws will end up in this code. } }, actions: { diff --git a/services/traction/api/endpoints/models/webhooks.py b/services/traction/api/endpoints/models/webhooks.py index 85d4c2139..012116403 100644 --- a/services/traction/api/endpoints/models/webhooks.py +++ b/services/traction/api/endpoints/models/webhooks.py @@ -62,8 +62,6 @@ class TenantEventTopicType(str, Enum): connection = "connection" issuer = "issuer" schema = "schema" - issue_cred = "issue_cred" - present_req = "present_req" issuer_cred_rev = "issuer_cred_rev" diff --git a/services/traction/api/services/IssueCredentialWorkflow.py b/services/traction/api/services/IssueCredentialWorkflow.py index 5ed106d3d..51aa58369 100644 --- a/services/traction/api/services/IssueCredentialWorkflow.py +++ b/services/traction/api/services/IssueCredentialWorkflow.py @@ -121,11 +121,6 @@ async def find_workflow_id(cls, profile: Profile, webhook_message: dict): issue_cred = await issue_repo.create(issue_cred) logger.debug(f">>> created new cred issue: {issue_cred}") - # if new, and offer_received, send webhook to tenant - logger.info(f">>> sending webhook with cred offer: {issue_cred}") - await TenantWorkflowNotifier(profile.db).issuer_workflow_cred_offer( - issue_cred - ) # return None - we want the tenant to accept the credential offer return None @@ -219,11 +214,6 @@ async def run_step(self, webhook_message: dict = None) -> TenantWorkflowRead: issue_cred, webhook_message ) - logger.info(f">>> sending credential acked: {issue_cred}") - await self.workflow_notifier.issuer_workflow_credential_acked( - issue_cred - ) - # finish off our workflow await self.complete_workflow() diff --git a/services/traction/api/services/PresentCredentialWorkflow.py b/services/traction/api/services/PresentCredentialWorkflow.py index 81d5e17b0..7827ae6d8 100644 --- a/services/traction/api/services/PresentCredentialWorkflow.py +++ b/services/traction/api/services/PresentCredentialWorkflow.py @@ -19,7 +19,6 @@ from api.endpoints.models.tenant_workflow import ( TenantWorkflowStateType, ) -from api.services.tenant_workflow_notifier import TenantWorkflowNotifier from api.endpoints.models.credentials import ( PresentCredentialProtocolType, PresentationStateType, @@ -109,11 +108,6 @@ async def find_workflow_id(cls, profile: Profile, webhook_message: dict): ) present_cred = await present_repo.create(present_cred) logger.warn(f">>> created new present request: {present_cred}") - - # if new, and offer_received, send webhook to tenant - logger.info(f">>> sending webhook with proof req: {present_cred}") - notifier = TenantWorkflowNotifier(profile.db) - await notifier.verifier_workflow_proof_req(present_cred) # return None - we want the tenant to respond to the request return None @@ -171,15 +165,6 @@ async def run_step(self, webhook_message: dict = None) -> TenantWorkflowRead: present_cred, webhook_state ) - if webhook_state == PresentationStateType.verified: - # if verified, send webhook to tenant - logger.info( - f">>> sending webhook with verified proof: {present_cred}" - ) - await self.workflow_notifier.verifier_workflow_proof_req( - present_cred - ) - if ( webhook_state == PresentationStateType.presentation_acked or webhook_state == PresentationStateType.verified diff --git a/services/traction/api/services/tenant_workflow_notifier.py b/services/traction/api/services/tenant_workflow_notifier.py index f02c86d7f..14946810b 100644 --- a/services/traction/api/services/tenant_workflow_notifier.py +++ b/services/traction/api/services/tenant_workflow_notifier.py @@ -6,7 +6,6 @@ from api.db.models.tenant_connection import TenantConnectionRead from api.db.models.tenant_issuer import TenantIssuerRead from api.db.models.tenant_schema import TenantSchemaRead -from api.db.models.present_credential import PresentCredentialRead from api.endpoints.models.webhooks import ( TenantEventTopicType, TRACTION_EVENT_PREFIX, @@ -46,40 +45,6 @@ async def issuer_workflow_connection_active( await profile.notify(event_topic, {"topic": topic, "payload": payload}) - async def issuer_workflow_credential_acked(self, issued_cred: IssueCredentialRead): - logger.info("issued credential acknowledged") - # emit an event for any interested listeners - profile = Profile(issued_cred.wallet_id, issued_cred.tenant_id, self.db) - topic = TenantEventTopicType.issue_cred - event_topic = TRACTION_EVENT_PREFIX + topic - logger.info(f"profile.notify {event_topic}") - - # TODO: Webhook payload schema's should become pydantic models? - payload = { - "status": issued_cred.issue_state, - "role": issued_cred.issue_role, - "issued_credential": issued_cred.json(), - } - - await profile.notify(event_topic, {"topic": topic, "payload": payload}) - - async def issuer_workflow_cred_offer(self, cred_offer: IssueCredentialRead): - logger.info("received cred offer") - # emit an event for any interested listeners - profile = Profile(cred_offer.wallet_id, cred_offer.tenant_id, self.db) - topic = TenantEventTopicType.issue_cred - event_topic = TRACTION_EVENT_PREFIX + topic - logger.info(f"profile.notify {event_topic}") - - # TODO: Webhook payload schema's should become pydantic models? - payload = { - "status": "offer_received", - "credential": cred_offer.json(), - "cred_issue_id": str(cred_offer.id), - } - - await profile.notify(event_topic, {"topic": topic, "payload": payload}) - async def issuer_workflow_cred_revoc( self, cred_info: IssueCredentialRead, comment: str ): @@ -133,20 +98,3 @@ async def schema_workflow_completed(self, tenant_schema: TenantSchemaRead): } await profile.notify(event_topic, {"topic": topic, "payload": payload}) - - async def verifier_workflow_proof_req(self, present_req: PresentCredentialRead): - logger.info("received proof request") - # emit an event for any interested listeners - profile = Profile(present_req.wallet_id, present_req.tenant_id, self.db) - topic = TenantEventTopicType.present_req - event_topic = TRACTION_EVENT_PREFIX + topic - logger.info(f"profile.notify {event_topic}") - - # TODO: Webhook payload schema's should become pydantic models? - payload = { - "status": present_req.present_state, - "present_req": present_req.json(), - "present_req_id": str(present_req.id), - } - - await profile.notify(event_topic, {"topic": topic, "payload": payload})