mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
show alias or username plus foreign-communityName in Tx-Lists
This commit is contained in:
parent
4f3bb51b02
commit
d64603268e
13
backend/src/graphql/arg/UserArgs.ts
Normal file
13
backend/src/graphql/arg/UserArgs.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { IsString } from 'class-validator'
|
||||
import { ArgsType, Field } from 'type-graphql'
|
||||
|
||||
@ArgsType()
|
||||
export class UserArgs {
|
||||
@Field({ nullable: false })
|
||||
@IsString()
|
||||
identifier: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
@IsString()
|
||||
communityIdentifier?: string
|
||||
}
|
||||
@ -38,6 +38,9 @@ export class User {
|
||||
@Field(() => String)
|
||||
communityUuid: string
|
||||
|
||||
@Field(() => String, { nullable: true })
|
||||
communityName: string | null
|
||||
|
||||
@Field(() => String)
|
||||
gradidoID: string
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ import { calculateBalance } from '@/util/validate'
|
||||
import { virtualLinkTransaction, virtualDecayTransaction } from '@/util/virtualTransactions'
|
||||
|
||||
import { BalanceResolver } from './BalanceResolver'
|
||||
import { isCommunityAuthenticated, isHomeCommunity } from './util/communities'
|
||||
import { getCommunityName, isCommunityAuthenticated, isHomeCommunity } from './util/communities'
|
||||
import { findUserByIdentifier } from './util/findUserByIdentifier'
|
||||
import { getLastTransaction } from './util/getLastTransaction'
|
||||
import { getTransactionList } from './util/getTransactionList'
|
||||
@ -275,13 +275,23 @@ export class TransactionResolver {
|
||||
logger.debug('found dbRemoteUser:', dbRemoteUser)
|
||||
const remoteUser = new User(dbRemoteUser)
|
||||
if (dbRemoteUser === null) {
|
||||
logger.debug('no dbRemoteUser found, init from tx:', transaction)
|
||||
if (transaction.linkedUserCommunityUuid !== null) {
|
||||
remoteUser.communityUuid = transaction.linkedUserCommunityUuid
|
||||
}
|
||||
remoteUser.gradidoID = transaction.linkedUserGradidoID
|
||||
remoteUser.firstName = transaction.linkedUserName
|
||||
remoteUser.lastName = 'GradidoID: ' + transaction.linkedUserGradidoID
|
||||
if (transaction.linkedUserName) {
|
||||
remoteUser.firstName = transaction.linkedUserName.slice(
|
||||
0,
|
||||
transaction.linkedUserName.indexOf(' '),
|
||||
)
|
||||
remoteUser.lastName = transaction.linkedUserName?.slice(
|
||||
transaction.linkedUserName.indexOf(' '),
|
||||
transaction.linkedUserName.length,
|
||||
)
|
||||
}
|
||||
}
|
||||
remoteUser.communityName = await getCommunityName(remoteUser.communityUuid)
|
||||
involvedRemoteUsers.push(remoteUser)
|
||||
}
|
||||
}
|
||||
@ -427,7 +437,6 @@ export class TransactionResolver {
|
||||
} else {
|
||||
// processing a x-community sendCoins
|
||||
logger.debug('X-Com: processing a x-community transaction...')
|
||||
console.log('X-Com: processing a x-community transaction...')
|
||||
if (!CONFIG.FEDERATION_XCOM_SENDCOINS_ENABLED) {
|
||||
throw new LogError('X-Community sendCoins disabled per configuration!')
|
||||
}
|
||||
@ -438,7 +447,6 @@ export class TransactionResolver {
|
||||
where: { communityUuid: recipientCommunityIdentifier },
|
||||
})
|
||||
logger.debug('recipient commuity: ', recipCom)
|
||||
console.log('recipient commuity: ', recipCom)
|
||||
let pendingResult: SendCoinsResult
|
||||
let committingResult: SendCoinsResult
|
||||
const creationDate = new Date()
|
||||
@ -454,10 +462,8 @@ export class TransactionResolver {
|
||||
recipientIdentifier,
|
||||
)
|
||||
logger.debug('processXComPendingSendCoins result: ', pendingResult)
|
||||
console.log('processXComPendingSendCoins result: ', pendingResult)
|
||||
if (pendingResult.vote && pendingResult.recipGradidoID) {
|
||||
logger.debug('vor processXComCommittingSendCoins... ')
|
||||
console.log('vor processXComCommittingSendCoins... ')
|
||||
committingResult = await processXComCommittingSendCoins(
|
||||
recipCom,
|
||||
homeCom,
|
||||
@ -468,7 +474,6 @@ export class TransactionResolver {
|
||||
pendingResult.recipGradidoID,
|
||||
)
|
||||
logger.debug('processXComCommittingSendCoins result: ', committingResult)
|
||||
console.log('processXComCommittingSendCoins result: ', committingResult)
|
||||
if (!committingResult.vote) {
|
||||
logger.fatal('FATAL ERROR: on processXComCommittingSendCoins for', committingResult)
|
||||
throw new LogError(
|
||||
@ -481,18 +486,12 @@ export class TransactionResolver {
|
||||
}
|
||||
// after successful x-com-tx store the recipient as foreign user
|
||||
logger.debug('store recipient as foreign user...')
|
||||
console.log('store recipient as foreign user...')
|
||||
if (await storeForeignUser(recipCom, committingResult)) {
|
||||
logger.info(
|
||||
'X-Com: new foreign user inserted successfully...',
|
||||
recipCom.communityUuid,
|
||||
committingResult.recipGradidoID,
|
||||
)
|
||||
console.log(
|
||||
'X-Com: new foreign user inserted successfully...',
|
||||
recipCom.communityUuid,
|
||||
committingResult.recipGradidoID,
|
||||
)
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
@ -12,6 +12,7 @@ import i18n from 'i18n'
|
||||
import { Resolver, Query, Args, Arg, Authorized, Ctx, Mutation, Int } from 'type-graphql'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
|
||||
import { UserArgs } from '@arg//UserArgs'
|
||||
import { CreateUserArgs } from '@arg/CreateUserArgs'
|
||||
import { Paginated } from '@arg/Paginated'
|
||||
import { SearchUsersFilters } from '@arg/SearchUsersFilters'
|
||||
@ -64,6 +65,7 @@ import random from 'random-bigint'
|
||||
import { randombytes_random } from 'sodium-native'
|
||||
|
||||
import { FULL_CREATION_AVAILABLE } from './const/const'
|
||||
import { getCommunityName, getHomeCommunity } from './util/communities'
|
||||
import { getUserCreations } from './util/creations'
|
||||
import { findUserByIdentifier } from './util/findUserByIdentifier'
|
||||
import { findUsers } from './util/findUsers'
|
||||
@ -810,10 +812,17 @@ export class UserResolver {
|
||||
@Authorized([RIGHTS.USER])
|
||||
@Query(() => User)
|
||||
async user(
|
||||
@Arg('identifier') identifier: string,
|
||||
@Arg('communityIdentifier') communityIdentifier?: string,
|
||||
@Args()
|
||||
{ identifier, communityIdentifier }: UserArgs,
|
||||
): Promise<User> {
|
||||
return new User(await findUserByIdentifier(identifier, communityIdentifier))
|
||||
const foundDbUser = await findUserByIdentifier(identifier, communityIdentifier)
|
||||
const modelUser = new User(foundDbUser)
|
||||
if (!foundDbUser.communityUuid) {
|
||||
modelUser.communityName = (await Promise.resolve(getHomeCommunity())).name
|
||||
} else {
|
||||
modelUser.communityName = await getCommunityName(foundDbUser.communityUuid)
|
||||
}
|
||||
return modelUser
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -15,6 +15,12 @@ export async function isHomeCommunity(communityIdentifier: string): Promise<bool
|
||||
}
|
||||
}
|
||||
|
||||
export async function getHomeCommunity(): Promise<DbCommunity> {
|
||||
return await DbCommunity.findOneOrFail({
|
||||
where: [{ foreign: true }],
|
||||
})
|
||||
}
|
||||
|
||||
export async function getCommunityUrl(communityIdentifier: string): Promise<string> {
|
||||
const community = await DbCommunity.findOneOrFail({
|
||||
where: [
|
||||
|
||||
@ -370,7 +370,7 @@ export const adminListContributionMessages = gql`
|
||||
`
|
||||
|
||||
export const user = gql`
|
||||
query ($identifier: String!, $communityIdentifier?: String) {
|
||||
query ($identifier: String!, $communityIdentifier: String) {
|
||||
user(identifier: $identifier, $communityIdentifier: $communityIdentifier) {
|
||||
firstName
|
||||
lastName
|
||||
|
||||
@ -36,13 +36,22 @@ export default {
|
||||
methods: {
|
||||
async tunnelEmail() {
|
||||
if (this.$route.path !== '/send') await this.$router.push({ path: '/send' })
|
||||
this.$router.push({ query: { gradidoID: this.linkedUser.gradidoID } })
|
||||
this.$router.push({
|
||||
query: {
|
||||
gradidoID: this.linkedUser.gradidoID,
|
||||
communityUuid: this.linkedUser.communityUuid,
|
||||
},
|
||||
})
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
itemText() {
|
||||
return this.linkedUser
|
||||
? this.linkedUser.firstName + ' ' + this.linkedUser.lastName
|
||||
? this.linkedUser.alias
|
||||
? this.linkedUser.alias +
|
||||
(this.linkedUser.communityName ? ' / ' + this.linkedUser.communityName : '')
|
||||
: this.linkedUser.firstName + ' ' + this.linkedUser.lastName +
|
||||
(this.linkedUser.communityName ? ' / ' + this.linkedUser.communityName : '')
|
||||
: this.text
|
||||
},
|
||||
},
|
||||
|
||||
@ -40,7 +40,10 @@ export const transactionsQuery = gql`
|
||||
linkedUser {
|
||||
firstName
|
||||
lastName
|
||||
communityUuid
|
||||
communityName
|
||||
gradidoID
|
||||
alias
|
||||
}
|
||||
decay {
|
||||
decay
|
||||
@ -281,6 +284,7 @@ export const user = gql`
|
||||
user(identifier: $identifier) {
|
||||
firstName
|
||||
lastName
|
||||
communityName
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user