mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
return dbRemoteUser in transactions list
This commit is contained in:
parent
6582cbcb39
commit
6f5e5175b2
@ -8,6 +8,8 @@ export class User {
|
||||
constructor(user: dbUser | null) {
|
||||
if (user) {
|
||||
this.id = user.id
|
||||
this.foreign = user.foreign
|
||||
this.communityUuid = user.communityUuid
|
||||
this.gradidoID = user.gradidoID
|
||||
this.alias = user.alias
|
||||
if (user.emailContact) {
|
||||
@ -30,6 +32,12 @@ export class User {
|
||||
@Field(() => Int)
|
||||
id: number
|
||||
|
||||
@Field(() => Boolean)
|
||||
foreign: boolean
|
||||
|
||||
@Field(() => String)
|
||||
communityUuid: string
|
||||
|
||||
@Field(() => String)
|
||||
gradidoID: string
|
||||
|
||||
|
||||
@ -251,18 +251,40 @@ export class TransactionResolver {
|
||||
// find involved users; I am involved
|
||||
const involvedUserIds: number[] = [user.id]
|
||||
const involvedRemoteUsers: User[] = []
|
||||
userTransactions.forEach((transaction: dbTransaction) => {
|
||||
// userTransactions.forEach((transaction: dbTransaction) => {
|
||||
// use normal for loop because of timing problems with await in forEach-loop
|
||||
for (const transaction of userTransactions) {
|
||||
if (transaction.linkedUserId && !involvedUserIds.includes(transaction.linkedUserId)) {
|
||||
involvedUserIds.push(transaction.linkedUserId)
|
||||
}
|
||||
if (!transaction.linkedUserId && transaction.linkedUserGradidoID) {
|
||||
const remoteUser = new User(null)
|
||||
remoteUser.gradidoID = transaction.linkedUserGradidoID
|
||||
remoteUser.firstName = transaction.linkedUserName
|
||||
remoteUser.lastName = '(GradidoID: ' + transaction.linkedUserGradidoID + ')'
|
||||
logger.debug(
|
||||
'search for remoteUser...',
|
||||
transaction.linkedUserCommunityUuid,
|
||||
transaction.linkedUserGradidoID,
|
||||
)
|
||||
const dbRemoteUser = await dbUser.findOne({
|
||||
where: [
|
||||
{
|
||||
foreign: true,
|
||||
communityUuid: transaction.linkedUserCommunityUuid ?? undefined,
|
||||
gradidoID: transaction.linkedUserGradidoID,
|
||||
},
|
||||
],
|
||||
})
|
||||
logger.debug('found dbRemoteUser:', dbRemoteUser)
|
||||
const remoteUser = new User(dbRemoteUser)
|
||||
if (dbRemoteUser === null) {
|
||||
if (transaction.linkedUserCommunityUuid !== null) {
|
||||
remoteUser.communityUuid = transaction.linkedUserCommunityUuid
|
||||
}
|
||||
remoteUser.gradidoID = transaction.linkedUserGradidoID
|
||||
remoteUser.firstName = transaction.linkedUserName
|
||||
remoteUser.lastName = 'GradidoID: ' + transaction.linkedUserGradidoID
|
||||
}
|
||||
involvedRemoteUsers.push(remoteUser)
|
||||
}
|
||||
})
|
||||
}
|
||||
logger.debug(`involvedUserIds=`, involvedUserIds)
|
||||
logger.debug(`involvedRemoteUsers=`, involvedRemoteUsers)
|
||||
|
||||
@ -337,7 +359,7 @@ export class TransactionResolver {
|
||||
(userTransactions.length && userTransactions[0].balance) || new Decimal(0),
|
||||
),
|
||||
)
|
||||
logger.debug(`transactions=${transactions}`)
|
||||
logger.debug(`transactions=`, transactions)
|
||||
}
|
||||
}
|
||||
|
||||
@ -364,7 +386,7 @@ export class TransactionResolver {
|
||||
}
|
||||
transactions.push(new Transaction(userTransaction, self, linkedUser))
|
||||
})
|
||||
logger.debug(`TransactionTypeId.CREATION: transactions=${transactions}`)
|
||||
logger.debug(`TransactionTypeId.CREATION: transactions=`, transactions)
|
||||
|
||||
transactions.forEach((transaction: Transaction) => {
|
||||
if (transaction.typeId !== TransactionTypeId.DECAY) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user