From 715d51272cfb04f7a4ac78ea5b6415822504b060 Mon Sep 17 00:00:00 2001 From: einhorn_b Date: Tue, 12 Oct 2021 14:42:31 +0200 Subject: [PATCH] check if recipiant account is not disabled --- backend/src/graphql/resolver/TransactionResolver.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index 2c2c60850..c488d8023 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -324,6 +324,12 @@ async function sendCoins( throw new Error("user hasn't enough GDD") } + const userRepository = getCustomRepository(UserRepository) + const recipiantUser = await userRepository.findByPubkeyHex(recipiantPublicKey) + if(recipiantUser && recipiantUser.disabled) { + throw new Error('recipiant user account is disabled') + } + const centAmount = Math.trunc(amount * 10000) const transferAmount = new proto.gradido.TransferAmount({ pubkey: senderUser.pubkey, @@ -332,6 +338,7 @@ async function sendCoins( // no group id is given so we assume it is a local transfer if (!groupId) { + const localTransfer = new proto.gradido.LocalTransfer({ sender: transferAmount, recipiant: fromHex(recipiantPublicKey), @@ -363,8 +370,8 @@ async function sendCoins( ed25519: sign, }) const sigMap = new proto.gradido.SignatureMap({ sigPair: [sigPair] }) - const userRepository = getCustomRepository(UserRepository) - const recipiantUser = await userRepository.findByPubkeyHex(recipiantPublicKey) + + // process db updates as transaction to able to rollback if an error occure