From 6718a177f5978219fca886e53d83891ac094906b Mon Sep 17 00:00:00 2001 From: Pranav Kakaraparti Date: Tue, 22 Aug 2023 01:02:42 -0500 Subject: [PATCH] feat: delete /trust_relationship/:id --- server/models/Trust.js | 8 ++++++++ server/services/TrustService.js | 5 ----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/server/models/Trust.js b/server/models/Trust.js index 9b1d0660..c14a7b1c 100644 --- a/server/models/Trust.js +++ b/server/models/Trust.js @@ -336,6 +336,14 @@ class Trust { 'wallet_trust.id': trustRelationshipId, }); const [trustRelationship] = trustRelationships; + + if(!trustRelationship){ + throw new HttpError( + 404, + 'No such trust relationship exists or it is not associated with the current wallet.' + ) + } + if (trustRelationship?.originator_wallet_id !== walletId) { throw new HttpError( 403, diff --git a/server/services/TrustService.js b/server/services/TrustService.js index a1a23a2c..664be38c 100644 --- a/server/services/TrustService.js +++ b/server/services/TrustService.js @@ -109,11 +109,6 @@ class TrustService { } async cancelTrustRequest({ walletLoginId, trustRelationshipId }) { - // check if trust relationship matching trustRelationshipId exists - // const trs = await this._session.getDB().select('*').from('wallet_trust').where('id', trustRelationshipId) - // console.log('TRUSTS', trs) - - return this._trust.cancelTrustRequest({ walletId: walletLoginId, trustRelationshipId,