adapt communityUuid treatment

This commit is contained in:
Claus-Peter Huebner 2023-10-12 00:26:22 +02:00
parent 053b92ed59
commit 1940b7b604
4 changed files with 12 additions and 5 deletions

View File

@ -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()

View File

@ -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)

View File

@ -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

View File

@ -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)