From 1940b7b604eadcd3e30cb9f656551b6d793b7ae8 Mon Sep 17 00:00:00 2001 From: Claus-Peter Huebner Date: Thu, 12 Oct 2023 00:26:22 +0200 Subject: [PATCH] adapt communityUuid treatment --- backend/src/graphql/arg/TransactionSendArgs.ts | 4 ++-- backend/src/graphql/resolver/TransactionResolver.ts | 9 +++++++-- .../src/graphql/resolver/util/findUserByIdentifier.ts | 3 ++- frontend/src/components/GddSend/TransactionForm.vue | 1 + 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/backend/src/graphql/arg/TransactionSendArgs.ts b/backend/src/graphql/arg/TransactionSendArgs.ts index 48827be8d..5bd8b89f7 100644 --- a/backend/src/graphql/arg/TransactionSendArgs.ts +++ b/backend/src/graphql/arg/TransactionSendArgs.ts @@ -7,9 +7,9 @@ import { IsPositiveDecimal } from '@/graphql/validator/Decimal' @ArgsType() export class TransactionSendArgs { - @Field(() => String, { nullable: true }) + @Field(() => String) @IsString() - recipientCommunityIdentifier?: string | null | undefined + recipientCommunityIdentifier: string @Field(() => String) @IsString() diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index 1c8761e7f..267f90596 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -426,11 +426,16 @@ export class TransactionResolver { if (!recipientCommunityIdentifier || (await isHomeCommunity(recipientCommunityIdentifier))) { // processing sendCoins within sender and recepient are both in home community - // validate recipient user - const recipientUser = await findUserByIdentifier(recipientIdentifier) + const recipientUser = await findUserByIdentifier( + recipientIdentifier, + recipientCommunityIdentifier, + ) if (!recipientUser) { throw new LogError('The recipient user was not found', recipientUser) } + if (recipientUser.foreign) { + throw new LogError('Found foreign recipient user for a local transaction:', recipientUser) + } await executeTransaction(amount, memo, senderUser, recipientUser) logger.info('successful executeTransaction', amount, memo, senderUser, recipientUser) diff --git a/backend/src/graphql/resolver/util/findUserByIdentifier.ts b/backend/src/graphql/resolver/util/findUserByIdentifier.ts index 0118dd865..6b7f1bccc 100644 --- a/backend/src/graphql/resolver/util/findUserByIdentifier.ts +++ b/backend/src/graphql/resolver/util/findUserByIdentifier.ts @@ -35,8 +35,9 @@ export const findUserByIdentifier = async ( } if (userContact.user.communityUuid !== communityIdentifier) { throw new LogError( - 'Found user to given contact, but belongs to foreign community', + 'Found user to given contact, but belongs to other community', identifier, + communityIdentifier, ) } user = userContact.user diff --git a/frontend/src/components/GddSend/TransactionForm.vue b/frontend/src/components/GddSend/TransactionForm.vue index db1bf0d1a..af1ab29c9 100644 --- a/frontend/src/components/GddSend/TransactionForm.vue +++ b/frontend/src/components/GddSend/TransactionForm.vue @@ -235,6 +235,7 @@ export default { update({ user, community }) { this.userName = `${user.firstName} ${user.lastName}` this.recipientCommunity.name = community.name + this.recipientCommunity.uuid = this.communityUuid }, error({ message }) { this.toastError(message)