mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-12 23:35:50 +00:00
fix problems
This commit is contained in:
parent
8b697bac5c
commit
49976b30b7
@ -8,7 +8,7 @@ import { CustomJwtPayload } from './CustomJwtPayload'
|
|||||||
export const decode = (token: string): CustomJwtPayload | null => {
|
export const decode = (token: string): CustomJwtPayload | null => {
|
||||||
if (!token) throw new LogError('401 Unauthorized')
|
if (!token) throw new LogError('401 Unauthorized')
|
||||||
try {
|
try {
|
||||||
return <CustomJwtPayload>verify(token, CONFIG.JWT_SECRET)
|
return verify(token, CONFIG.JWT_SECRET) as CustomJwtPayload
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ const constants = {
|
|||||||
DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0
|
DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0
|
||||||
LOG4JS_CONFIG: 'log4js-config.json',
|
LOG4JS_CONFIG: 'log4js-config.json',
|
||||||
// default log level on production should be info
|
// default log level on production should be info
|
||||||
LOG_LEVEL: process.env.LOG_LEVEL || 'info',
|
LOG_LEVEL: process.env.LOG_LEVEL ?? 'info',
|
||||||
CONFIG_VERSION: {
|
CONFIG_VERSION: {
|
||||||
DEFAULT: 'DEFAULT',
|
DEFAULT: 'DEFAULT',
|
||||||
EXPECTED: 'v15.2023-02-07',
|
EXPECTED: 'v15.2023-02-07',
|
||||||
@ -25,67 +25,67 @@ const constants = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const server = {
|
const server = {
|
||||||
PORT: process.env.PORT || 4000,
|
PORT: process.env.PORT ?? 4000,
|
||||||
JWT_SECRET: process.env.JWT_SECRET || 'secret123',
|
JWT_SECRET: process.env.JWT_SECRET ?? 'secret123',
|
||||||
JWT_EXPIRES_IN: process.env.JWT_EXPIRES_IN || '10m',
|
JWT_EXPIRES_IN: process.env.JWT_EXPIRES_IN ?? '10m',
|
||||||
GRAPHIQL: process.env.GRAPHIQL === 'true' || false,
|
GRAPHIQL: process.env.GRAPHIQL === 'true' || false,
|
||||||
GDT_API_URL: process.env.GDT_API_URL || 'https://gdt.gradido.net',
|
GDT_API_URL: process.env.GDT_API_URL ?? 'https://gdt.gradido.net',
|
||||||
PRODUCTION: process.env.NODE_ENV === 'production' || false,
|
PRODUCTION: process.env.NODE_ENV === 'production' || false,
|
||||||
}
|
}
|
||||||
|
|
||||||
const database = {
|
const database = {
|
||||||
DB_HOST: process.env.DB_HOST || 'localhost',
|
DB_HOST: process.env.DB_HOST ?? 'localhost',
|
||||||
DB_PORT: process.env.DB_PORT ? parseInt(process.env.DB_PORT) : 3306,
|
DB_PORT: process.env.DB_PORT ? parseInt(process.env.DB_PORT) : 3306,
|
||||||
DB_USER: process.env.DB_USER || 'root',
|
DB_USER: process.env.DB_USER ?? 'root',
|
||||||
DB_PASSWORD: process.env.DB_PASSWORD || '',
|
DB_PASSWORD: process.env.DB_PASSWORD ?? '',
|
||||||
DB_DATABASE: process.env.DB_DATABASE || 'gradido_community',
|
DB_DATABASE: process.env.DB_DATABASE ?? 'gradido_community',
|
||||||
TYPEORM_LOGGING_RELATIVE_PATH: process.env.TYPEORM_LOGGING_RELATIVE_PATH || 'typeorm.backend.log',
|
TYPEORM_LOGGING_RELATIVE_PATH: process.env.TYPEORM_LOGGING_RELATIVE_PATH ?? 'typeorm.backend.log',
|
||||||
}
|
}
|
||||||
|
|
||||||
const klicktipp = {
|
const klicktipp = {
|
||||||
KLICKTIPP: process.env.KLICKTIPP === 'true' || false,
|
KLICKTIPP: process.env.KLICKTIPP === 'true' || false,
|
||||||
KLICKTTIPP_API_URL: process.env.KLICKTIPP_API_URL || 'https://api.klicktipp.com',
|
KLICKTTIPP_API_URL: process.env.KLICKTIPP_API_URL ?? 'https://api.klicktipp.com',
|
||||||
KLICKTIPP_USER: process.env.KLICKTIPP_USER || 'gradido_test',
|
KLICKTIPP_USER: process.env.KLICKTIPP_USER ?? 'gradido_test',
|
||||||
KLICKTIPP_PASSWORD: process.env.KLICKTIPP_PASSWORD || 'secret321',
|
KLICKTIPP_PASSWORD: process.env.KLICKTIPP_PASSWORD ?? 'secret321',
|
||||||
KLICKTIPP_APIKEY_DE: process.env.KLICKTIPP_APIKEY_DE || 'SomeFakeKeyDE',
|
KLICKTIPP_APIKEY_DE: process.env.KLICKTIPP_APIKEY_DE ?? 'SomeFakeKeyDE',
|
||||||
KLICKTIPP_APIKEY_EN: process.env.KLICKTIPP_APIKEY_EN || 'SomeFakeKeyEN',
|
KLICKTIPP_APIKEY_EN: process.env.KLICKTIPP_APIKEY_EN ?? 'SomeFakeKeyEN',
|
||||||
}
|
}
|
||||||
|
|
||||||
const community = {
|
const community = {
|
||||||
COMMUNITY_NAME: process.env.COMMUNITY_NAME || 'Gradido Entwicklung',
|
COMMUNITY_NAME: process.env.COMMUNITY_NAME ?? 'Gradido Entwicklung',
|
||||||
COMMUNITY_URL: process.env.COMMUNITY_URL || 'http://localhost/',
|
COMMUNITY_URL: process.env.COMMUNITY_URL ?? 'http://localhost/',
|
||||||
COMMUNITY_REGISTER_URL: process.env.COMMUNITY_REGISTER_URL || 'http://localhost/register',
|
COMMUNITY_REGISTER_URL: process.env.COMMUNITY_REGISTER_URL ?? 'http://localhost/register',
|
||||||
COMMUNITY_REDEEM_URL: process.env.COMMUNITY_REDEEM_URL || 'http://localhost/redeem/{code}',
|
COMMUNITY_REDEEM_URL: process.env.COMMUNITY_REDEEM_URL ?? 'http://localhost/redeem/{code}',
|
||||||
COMMUNITY_REDEEM_CONTRIBUTION_URL:
|
COMMUNITY_REDEEM_CONTRIBUTION_URL:
|
||||||
process.env.COMMUNITY_REDEEM_CONTRIBUTION_URL || 'http://localhost/redeem/CL-{code}',
|
process.env.COMMUNITY_REDEEM_CONTRIBUTION_URL ?? 'http://localhost/redeem/CL-{code}',
|
||||||
COMMUNITY_DESCRIPTION:
|
COMMUNITY_DESCRIPTION:
|
||||||
process.env.COMMUNITY_DESCRIPTION || 'Die lokale Entwicklungsumgebung von Gradido.',
|
process.env.COMMUNITY_DESCRIPTION ?? 'Die lokale Entwicklungsumgebung von Gradido.',
|
||||||
COMMUNITY_SUPPORT_MAIL: process.env.COMMUNITY_SUPPORT_MAIL || 'support@supportmail.com',
|
COMMUNITY_SUPPORT_MAIL: process.env.COMMUNITY_SUPPORT_MAIL ?? 'support@supportmail.com',
|
||||||
}
|
}
|
||||||
|
|
||||||
const loginServer = {
|
const loginServer = {
|
||||||
LOGIN_APP_SECRET: process.env.LOGIN_APP_SECRET || '21ffbbc616fe',
|
LOGIN_APP_SECRET: process.env.LOGIN_APP_SECRET ?? '21ffbbc616fe',
|
||||||
LOGIN_SERVER_KEY: process.env.LOGIN_SERVER_KEY || 'a51ef8ac7ef1abf162fb7a65261acd7a',
|
LOGIN_SERVER_KEY: process.env.LOGIN_SERVER_KEY ?? 'a51ef8ac7ef1abf162fb7a65261acd7a',
|
||||||
}
|
}
|
||||||
|
|
||||||
const email = {
|
const email = {
|
||||||
EMAIL: process.env.EMAIL === 'true' || false,
|
EMAIL: process.env.EMAIL === 'true' || false,
|
||||||
EMAIL_TEST_MODUS: process.env.EMAIL_TEST_MODUS === 'true' || false,
|
EMAIL_TEST_MODUS: process.env.EMAIL_TEST_MODUS === 'true' || false,
|
||||||
EMAIL_TEST_RECEIVER: process.env.EMAIL_TEST_RECEIVER || 'stage1@gradido.net',
|
EMAIL_TEST_RECEIVER: process.env.EMAIL_TEST_RECEIVER ?? 'stage1@gradido.net',
|
||||||
EMAIL_USERNAME: process.env.EMAIL_USERNAME || '',
|
EMAIL_USERNAME: process.env.EMAIL_USERNAME ?? '',
|
||||||
EMAIL_SENDER: process.env.EMAIL_SENDER || 'info@gradido.net',
|
EMAIL_SENDER: process.env.EMAIL_SENDER ?? 'info@gradido.net',
|
||||||
EMAIL_PASSWORD: process.env.EMAIL_PASSWORD || '',
|
EMAIL_PASSWORD: process.env.EMAIL_PASSWORD ?? '',
|
||||||
EMAIL_SMTP_URL: process.env.EMAIL_SMTP_URL || 'mailserver',
|
EMAIL_SMTP_URL: process.env.EMAIL_SMTP_URL ?? 'mailserver',
|
||||||
EMAIL_SMTP_PORT: Number(process.env.EMAIL_SMTP_PORT) || 1025,
|
EMAIL_SMTP_PORT: Number(process.env.EMAIL_SMTP_PORT) || 1025,
|
||||||
// eslint-disable-next-line no-unneeded-ternary
|
// eslint-disable-next-line no-unneeded-ternary
|
||||||
EMAIL_TLS: process.env.EMAIL_TLS === 'false' ? false : true,
|
EMAIL_TLS: process.env.EMAIL_TLS === 'false' ? false : true,
|
||||||
EMAIL_LINK_VERIFICATION:
|
EMAIL_LINK_VERIFICATION:
|
||||||
process.env.EMAIL_LINK_VERIFICATION || 'http://localhost/checkEmail/{optin}{code}',
|
process.env.EMAIL_LINK_VERIFICATION ?? 'http://localhost/checkEmail/{optin}{code}',
|
||||||
EMAIL_LINK_SETPASSWORD:
|
EMAIL_LINK_SETPASSWORD:
|
||||||
process.env.EMAIL_LINK_SETPASSWORD || 'http://localhost/reset-password/{optin}',
|
process.env.EMAIL_LINK_SETPASSWORD ?? 'http://localhost/reset-password/{optin}',
|
||||||
EMAIL_LINK_FORGOTPASSWORD:
|
EMAIL_LINK_FORGOTPASSWORD:
|
||||||
process.env.EMAIL_LINK_FORGOTPASSWORD || 'http://localhost/forgot-password',
|
process.env.EMAIL_LINK_FORGOTPASSWORD ?? 'http://localhost/forgot-password',
|
||||||
EMAIL_LINK_OVERVIEW: process.env.EMAIL_LINK_OVERVIEW || 'http://localhost/overview',
|
EMAIL_LINK_OVERVIEW: process.env.EMAIL_LINK_OVERVIEW ?? 'http://localhost/overview',
|
||||||
// time in minutes a optin code is valid
|
// time in minutes a optin code is valid
|
||||||
EMAIL_CODE_VALID_TIME: process.env.EMAIL_CODE_VALID_TIME
|
EMAIL_CODE_VALID_TIME: process.env.EMAIL_CODE_VALID_TIME
|
||||||
? parseInt(process.env.EMAIL_CODE_VALID_TIME) || 1440
|
? parseInt(process.env.EMAIL_CODE_VALID_TIME) || 1440
|
||||||
@ -98,14 +98,14 @@ const email = {
|
|||||||
|
|
||||||
const webhook = {
|
const webhook = {
|
||||||
// Elopage
|
// Elopage
|
||||||
WEBHOOK_ELOPAGE_SECRET: process.env.WEBHOOK_ELOPAGE_SECRET || 'secret',
|
WEBHOOK_ELOPAGE_SECRET: process.env.WEBHOOK_ELOPAGE_SECRET ?? 'secret',
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is needed by graphql-directive-auth
|
// This is needed by graphql-directive-auth
|
||||||
process.env.APP_SECRET = server.JWT_SECRET
|
process.env.APP_SECRET = server.JWT_SECRET
|
||||||
|
|
||||||
// Check config version
|
// Check config version
|
||||||
constants.CONFIG_VERSION.CURRENT = process.env.CONFIG_VERSION || constants.CONFIG_VERSION.DEFAULT
|
constants.CONFIG_VERSION.CURRENT = process.env.CONFIG_VERSION ?? constants.CONFIG_VERSION.DEFAULT
|
||||||
if (
|
if (
|
||||||
![constants.CONFIG_VERSION.EXPECTED, constants.CONFIG_VERSION.DEFAULT].includes(
|
![constants.CONFIG_VERSION.EXPECTED, constants.CONFIG_VERSION.DEFAULT].includes(
|
||||||
constants.CONFIG_VERSION.CURRENT,
|
constants.CONFIG_VERSION.CURRENT,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { GraphQLClient } from 'graphql-request'
|
import { GraphQLClient } from 'graphql-request'
|
||||||
import { PatchedRequestInit } from 'graphql-request/dist/types'
|
import { PatchedRequestInit } from 'graphql-request/dist/types'
|
||||||
|
|
||||||
type ClientInstance = {
|
interface ClientInstance {
|
||||||
url: string
|
url: string
|
||||||
// eslint-disable-next-line no-use-before-define
|
// eslint-disable-next-line no-use-before-define
|
||||||
client: GraphQLGetClient
|
client: GraphQLGetClient
|
||||||
|
|||||||
@ -54,7 +54,7 @@ export async function validateCommunities(): Promise<void> {
|
|||||||
} else {
|
} else {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`Federation: received not matching publicKey -> received: ${
|
`Federation: received not matching publicKey -> received: ${
|
||||||
pubKey || 'null'
|
pubKey ?? 'null'
|
||||||
}, expected: ${dbCom.publicKey.toString()} `,
|
}, expected: ${dbCom.publicKey.toString()} `,
|
||||||
)
|
)
|
||||||
// DbCommunity.delete({ id: dbCom.id })
|
// DbCommunity.delete({ id: dbCom.id })
|
||||||
|
|||||||
@ -12,7 +12,7 @@ export const isAuthorized: AuthChecker<Context> = async ({ context }, rights) =>
|
|||||||
context.role = ROLE_UNAUTHORIZED // unauthorized user
|
context.role = ROLE_UNAUTHORIZED // unauthorized user
|
||||||
|
|
||||||
// is rights an inalienable right?
|
// is rights an inalienable right?
|
||||||
if ((<RIGHTS[]>rights).reduce((acc, right) => acc && INALIENABLE_RIGHTS.includes(right), true))
|
if ((rights as RIGHTS[]).reduce((acc, right) => acc && INALIENABLE_RIGHTS.includes(right), true))
|
||||||
return true
|
return true
|
||||||
|
|
||||||
// Do we have a token?
|
// Do we have a token?
|
||||||
@ -43,7 +43,7 @@ export const isAuthorized: AuthChecker<Context> = async ({ context }, rights) =>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check for correct rights
|
// check for correct rights
|
||||||
const missingRights = (<RIGHTS[]>rights).filter((right) => !context.role?.hasRight(right))
|
const missingRights = (rights as RIGHTS[]).filter((right) => !context.role?.hasRight(right))
|
||||||
if (missingRights.length !== 0) {
|
if (missingRights.length !== 0) {
|
||||||
throw new LogError('401 Unauthorized')
|
throw new LogError('401 Unauthorized')
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ export class Balance {
|
|||||||
linkCount: number
|
linkCount: number
|
||||||
}) {
|
}) {
|
||||||
this.balance = data.balance
|
this.balance = data.balance
|
||||||
this.balanceGDT = data.balanceGDT || null
|
this.balanceGDT = data.balanceGDT ?? null
|
||||||
this.count = data.count
|
this.count = data.count
|
||||||
this.linkCount = data.linkCount
|
this.linkCount = data.linkCount
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,13 +43,12 @@ export class Transaction {
|
|||||||
this.memo = transaction.memo
|
this.memo = transaction.memo
|
||||||
this.creationDate = transaction.creationDate
|
this.creationDate = transaction.creationDate
|
||||||
this.linkedUser = linkedUser
|
this.linkedUser = linkedUser
|
||||||
this.linkedTransactionId = transaction.linkedTransactionId || null
|
this.linkedTransactionId = transaction.linkedTransactionId ?? null
|
||||||
this.linkId = transaction.contribution
|
this.linkId = transaction.contribution
|
||||||
? transaction.contribution.contributionLinkId
|
? transaction.contribution.contributionLinkId
|
||||||
: transaction.transactionLinkId || null
|
: transaction.transactionLinkId ?? null
|
||||||
this.previousBalance =
|
this.previousBalance =
|
||||||
(transaction.previousTransaction &&
|
transaction.previousTransaction?.balance.toDecimalPlaces(2, Decimal.ROUND_DOWN) ??
|
||||||
transaction.previousTransaction.balance.toDecimalPlaces(2, Decimal.ROUND_DOWN)) ||
|
|
||||||
new Decimal(0)
|
new Decimal(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -70,7 +70,10 @@ export class BalanceResolver {
|
|||||||
now,
|
now,
|
||||||
)
|
)
|
||||||
logger.info(
|
logger.info(
|
||||||
`calculatedDecay(balance=${lastTransaction.balance}, balanceDate=${lastTransaction.balanceDate})=${calculatedDecay}`,
|
'calculatedDecay',
|
||||||
|
lastTransaction.balance,
|
||||||
|
lastTransaction.balanceDate,
|
||||||
|
calculatedDecay,
|
||||||
)
|
)
|
||||||
|
|
||||||
// The final balance is reduced by the link amount withheld
|
// The final balance is reduced by the link amount withheld
|
||||||
@ -96,9 +99,7 @@ export class BalanceResolver {
|
|||||||
count,
|
count,
|
||||||
linkCount,
|
linkCount,
|
||||||
})
|
})
|
||||||
logger.info(
|
logger.info('new Balance', balance, balanceGDT, count, linkCount, newBalance)
|
||||||
`new Balance(balance=${balance}, balanceGDT=${balanceGDT}, count=${count}, linkCount=${linkCount}) = ${newBalance}`,
|
|
||||||
)
|
|
||||||
|
|
||||||
return newBalance
|
return newBalance
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,7 +66,7 @@ let testEnv: {
|
|||||||
query: ApolloServerTestClient['query']
|
query: ApolloServerTestClient['query']
|
||||||
con: Connection
|
con: Connection
|
||||||
}
|
}
|
||||||
let creation: Contribution | void
|
let creation: Contribution | null
|
||||||
let admin: User
|
let admin: User
|
||||||
let pendingContribution: any
|
let pendingContribution: any
|
||||||
let inProgressContribution: any
|
let inProgressContribution: any
|
||||||
@ -2071,7 +2071,7 @@ describe('ContributionResolver', () => {
|
|||||||
mutate({
|
mutate({
|
||||||
mutation: updateContribution,
|
mutation: updateContribution,
|
||||||
variables: {
|
variables: {
|
||||||
contributionId: (adminContribution && adminContribution.id) || -1,
|
contributionId: adminContribution?.id ?? -1,
|
||||||
amount: 100.0,
|
amount: 100.0,
|
||||||
memo: 'Test Test Test',
|
memo: 'Test Test Test',
|
||||||
creationDate: new Date().toString(),
|
creationDate: new Date().toString(),
|
||||||
@ -2565,8 +2565,8 @@ describe('ContributionResolver', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('confirm two creations one after the other quickly', () => {
|
describe('confirm two creations one after the other quickly', () => {
|
||||||
let c1: Contribution | void
|
let c1: Contribution | null
|
||||||
let c2: Contribution | void
|
let c2: Contribution | null
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
|
|||||||
@ -269,7 +269,7 @@ export class ContributionResolver {
|
|||||||
withDeleted: true,
|
withDeleted: true,
|
||||||
relations: ['user'],
|
relations: ['user'],
|
||||||
})
|
})
|
||||||
if (!emailContact || !emailContact.user) {
|
if (!emailContact?.user) {
|
||||||
throw new LogError('Could not find user', email)
|
throw new LogError('Could not find user', email)
|
||||||
}
|
}
|
||||||
if (emailContact.deletedAt || emailContact.user.deletedAt) {
|
if (emailContact.deletedAt || emailContact.user.deletedAt) {
|
||||||
|
|||||||
@ -817,8 +817,8 @@ describe('TransactionLinkResolver', () => {
|
|||||||
const bibisTransaktionLinks = transactionLinks.filter(
|
const bibisTransaktionLinks = transactionLinks.filter(
|
||||||
(transactionLink) => transactionLink.email === 'bibi@bloxberg.de',
|
(transactionLink) => transactionLink.email === 'bibi@bloxberg.de',
|
||||||
)
|
)
|
||||||
for (let i = 0; i < bibisTransaktionLinks.length; i++) {
|
for (const bibisTransaktionLink of bibisTransaktionLinks) {
|
||||||
await transactionLinkFactory(testEnv, bibisTransaktionLinks[i])
|
await transactionLinkFactory(testEnv, bibisTransaktionLink)
|
||||||
}
|
}
|
||||||
|
|
||||||
// admin: only now log in
|
// admin: only now log in
|
||||||
|
|||||||
@ -146,7 +146,7 @@ export class TransactionLinkResolver {
|
|||||||
const transactionLink = await DbTransactionLink.findOneOrFail({ code }, { withDeleted: true })
|
const transactionLink = await DbTransactionLink.findOneOrFail({ code }, { withDeleted: true })
|
||||||
const user = await DbUser.findOneOrFail({ id: transactionLink.userId })
|
const user = await DbUser.findOneOrFail({ id: transactionLink.userId })
|
||||||
let redeemedBy: User | null = null
|
let redeemedBy: User | null = null
|
||||||
if (transactionLink && transactionLink.redeemedBy) {
|
if (transactionLink?.redeemedBy) {
|
||||||
redeemedBy = new User(await DbUser.findOneOrFail({ id: transactionLink.redeemedBy }))
|
redeemedBy = new User(await DbUser.findOneOrFail({ id: transactionLink.redeemedBy }))
|
||||||
}
|
}
|
||||||
return new TransactionLink(transactionLink, new User(user), redeemedBy)
|
return new TransactionLink(transactionLink, new User(user), redeemedBy)
|
||||||
|
|||||||
@ -48,9 +48,7 @@ export const executeTransaction = async (
|
|||||||
// acquire lock
|
// acquire lock
|
||||||
const releaseLock = await TRANSACTIONS_LOCK.acquire()
|
const releaseLock = await TRANSACTIONS_LOCK.acquire()
|
||||||
try {
|
try {
|
||||||
logger.info(
|
logger.info('executeTransaction', amount, memo, sender, recipient)
|
||||||
`executeTransaction(amount=${amount}, memo=${memo}, sender=${sender}, recipient=${recipient})...`,
|
|
||||||
)
|
|
||||||
|
|
||||||
if (sender.id === recipient.id) {
|
if (sender.id === recipient.id) {
|
||||||
throw new LogError('Sender and Recipient are the same', sender.id)
|
throw new LogError('Sender and Recipient are the same', sender.id)
|
||||||
@ -119,10 +117,10 @@ export const executeTransaction = async (
|
|||||||
// Save linked transaction id for send
|
// Save linked transaction id for send
|
||||||
transactionSend.linkedTransactionId = transactionReceive.id
|
transactionSend.linkedTransactionId = transactionReceive.id
|
||||||
await queryRunner.manager.update(dbTransaction, { id: transactionSend.id }, transactionSend)
|
await queryRunner.manager.update(dbTransaction, { id: transactionSend.id }, transactionSend)
|
||||||
logger.debug(`send Transaction updated: ${transactionSend}`)
|
logger.debug('send Transaction updated', transactionSend)
|
||||||
|
|
||||||
if (transactionLink) {
|
if (transactionLink) {
|
||||||
logger.info(`transactionLink: ${transactionLink}`)
|
logger.info('transactionLink', transactionLink)
|
||||||
transactionLink.redeemedAt = receivedCallDate
|
transactionLink.redeemedAt = receivedCallDate
|
||||||
transactionLink.redeemedBy = recipient.id
|
transactionLink.redeemedBy = recipient.id
|
||||||
await queryRunner.manager.update(
|
await queryRunner.manager.update(
|
||||||
@ -271,8 +269,8 @@ export class TransactionResolver {
|
|||||||
sumAmount.mul(-1),
|
sumAmount.mul(-1),
|
||||||
sumHoldAvailableAmount.mul(-1),
|
sumHoldAvailableAmount.mul(-1),
|
||||||
sumHoldAvailableAmount.minus(sumAmount.toString()).mul(-1),
|
sumHoldAvailableAmount.minus(sumAmount.toString()).mul(-1),
|
||||||
firstDate || now,
|
firstDate ?? now,
|
||||||
lastDate || now,
|
lastDate ?? now,
|
||||||
self,
|
self,
|
||||||
(userTransactions.length && userTransactions[0].balance) || new Decimal(0),
|
(userTransactions.length && userTransactions[0].balance) || new Decimal(0),
|
||||||
),
|
),
|
||||||
@ -325,9 +323,7 @@ export class TransactionResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await executeTransaction(amount, memo, senderUser, recipientUser)
|
await executeTransaction(amount, memo, senderUser, recipientUser)
|
||||||
logger.info(
|
logger.info('successful executeTransaction', amount, memo, senderUser, recipientUser)
|
||||||
`successful executeTransaction(amount=${amount}, memo=${memo}, senderUser=${senderUser}, recipientUser=${recipientUser})`,
|
|
||||||
)
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -94,7 +94,7 @@ const newEmailContact = (email: string, userId: number): DbUserContact => {
|
|||||||
emailContact.emailChecked = false
|
emailContact.emailChecked = false
|
||||||
emailContact.emailOptInTypeId = OptInType.EMAIL_OPT_IN_REGISTER
|
emailContact.emailOptInTypeId = OptInType.EMAIL_OPT_IN_REGISTER
|
||||||
emailContact.emailVerificationCode = random(64)
|
emailContact.emailVerificationCode = random(64)
|
||||||
logger.debug(`newEmailContact...successful: ${emailContact}`)
|
logger.debug('newEmailContact...successful', emailContact)
|
||||||
return emailContact
|
return emailContact
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ export class UserResolver {
|
|||||||
email = email.trim().toLowerCase()
|
email = email.trim().toLowerCase()
|
||||||
if (await checkEmailExists(email)) {
|
if (await checkEmailExists(email)) {
|
||||||
const foundUser = await findUserByEmail(email)
|
const foundUser = await findUserByEmail(email)
|
||||||
logger.info(`DbUser.findOne(email=${email}) = ${foundUser}`)
|
logger.info('DbUser.findOne', email, foundUser)
|
||||||
|
|
||||||
if (foundUser) {
|
if (foundUser) {
|
||||||
// ATTENTION: this logger-message will be exactly expected during tests, next line
|
// ATTENTION: this logger-message will be exactly expected during tests, next line
|
||||||
@ -275,7 +275,7 @@ export class UserResolver {
|
|||||||
dbUser.firstName = firstName
|
dbUser.firstName = firstName
|
||||||
dbUser.lastName = lastName
|
dbUser.lastName = lastName
|
||||||
dbUser.language = language
|
dbUser.language = language
|
||||||
dbUser.publisherId = publisherId || 0
|
dbUser.publisherId = publisherId ?? 0
|
||||||
dbUser.passwordEncryptionType = PasswordEncryptionType.NO_PASSWORD
|
dbUser.passwordEncryptionType = PasswordEncryptionType.NO_PASSWORD
|
||||||
logger.debug('new dbUser', dbUser)
|
logger.debug('new dbUser', dbUser)
|
||||||
if (redeemCode) {
|
if (redeemCode) {
|
||||||
@ -382,7 +382,7 @@ export class UserResolver {
|
|||||||
throw new LogError('Unable to save email verification code', user.emailContact)
|
throw new LogError('Unable to save email verification code', user.emailContact)
|
||||||
})
|
})
|
||||||
|
|
||||||
logger.info(`optInCode for ${email}=${user.emailContact}`)
|
logger.info('optInCode for', email, user.emailContact)
|
||||||
|
|
||||||
void sendResetPasswordEmail({
|
void sendResetPasswordEmail({
|
||||||
firstName: user.firstName,
|
firstName: user.firstName,
|
||||||
@ -486,7 +486,7 @@ export class UserResolver {
|
|||||||
async queryOptIn(@Arg('optIn') optIn: string): Promise<boolean> {
|
async queryOptIn(@Arg('optIn') optIn: string): Promise<boolean> {
|
||||||
logger.info(`queryOptIn(${optIn})...`)
|
logger.info(`queryOptIn(${optIn})...`)
|
||||||
const userContact = await DbUserContact.findOneOrFail({ emailVerificationCode: optIn })
|
const userContact = await DbUserContact.findOneOrFail({ emailVerificationCode: optIn })
|
||||||
logger.debug(`found optInCode=${userContact}`)
|
logger.debug('found optInCode', userContact)
|
||||||
// Code is only valid for `CONFIG.EMAIL_CODE_VALID_TIME` minutes
|
// Code is only valid for `CONFIG.EMAIL_CODE_VALID_TIME` minutes
|
||||||
if (!isEmailVerificationCodeValid(userContact.updatedAt || userContact.createdAt)) {
|
if (!isEmailVerificationCodeValid(userContact.updatedAt || userContact.createdAt)) {
|
||||||
throw new LogError(
|
throw new LogError(
|
||||||
@ -586,7 +586,7 @@ export class UserResolver {
|
|||||||
logger.info(`hasElopage()...`)
|
logger.info(`hasElopage()...`)
|
||||||
const userEntity = getUser(context)
|
const userEntity = getUser(context)
|
||||||
const elopageBuys = hasElopageBuys(userEntity.emailContact.email)
|
const elopageBuys = hasElopageBuys(userEntity.emailContact.email)
|
||||||
logger.debug(`has ElopageBuys = ${elopageBuys}`)
|
logger.debug('has ElopageBuys', elopageBuys)
|
||||||
return elopageBuys
|
return elopageBuys
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -643,7 +643,7 @@ export class UserResolver {
|
|||||||
return 'user.' + fieldName
|
return 'user.' + fieldName
|
||||||
}),
|
}),
|
||||||
searchText,
|
searchText,
|
||||||
filters || null,
|
filters ?? null,
|
||||||
currentPage,
|
currentPage,
|
||||||
pageSize,
|
pageSize,
|
||||||
)
|
)
|
||||||
@ -709,14 +709,14 @@ export class UserResolver {
|
|||||||
// change isAdmin
|
// change isAdmin
|
||||||
switch (user.isAdmin) {
|
switch (user.isAdmin) {
|
||||||
case null:
|
case null:
|
||||||
if (isAdmin === true) {
|
if (isAdmin) {
|
||||||
user.isAdmin = new Date()
|
user.isAdmin = new Date()
|
||||||
} else {
|
} else {
|
||||||
throw new LogError('User is already an usual user')
|
throw new LogError('User is already an usual user')
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
if (isAdmin === false) {
|
if (!isAdmin) {
|
||||||
user.isAdmin = null
|
user.isAdmin = null
|
||||||
} else {
|
} else {
|
||||||
throw new LogError('User is already admin')
|
throw new LogError('User is already admin')
|
||||||
|
|||||||
@ -24,7 +24,7 @@ export const findContributions = async (
|
|||||||
}
|
}
|
||||||
return DbContribution.findAndCount({
|
return DbContribution.findAndCount({
|
||||||
where: {
|
where: {
|
||||||
...(statusFilter && statusFilter.length && { contributionStatus: In(statusFilter) }),
|
...(statusFilter?.length && { contributionStatus: In(statusFilter) }),
|
||||||
...(userId && { userId }),
|
...(userId && { userId }),
|
||||||
},
|
},
|
||||||
withDeleted,
|
withDeleted,
|
||||||
|
|||||||
@ -14,7 +14,7 @@ export async function transactionLinkList(
|
|||||||
filters: TransactionLinkFilters | null,
|
filters: TransactionLinkFilters | null,
|
||||||
user: DbUser,
|
user: DbUser,
|
||||||
): Promise<TransactionLinkResult> {
|
): Promise<TransactionLinkResult> {
|
||||||
const { withDeleted, withExpired, withRedeemed } = filters || {
|
const { withDeleted, withExpired, withRedeemed } = filters ?? {
|
||||||
withDeleted: false,
|
withDeleted: false,
|
||||||
withExpired: false,
|
withExpired: false,
|
||||||
withRedeemed: false,
|
withRedeemed: false,
|
||||||
|
|||||||
@ -13,7 +13,7 @@ async function main() {
|
|||||||
console.log(`GraphIQL available at http://localhost:${CONFIG.PORT}`)
|
console.log(`GraphIQL available at http://localhost:${CONFIG.PORT}`)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
void startValidateCommunities(Number(CONFIG.FEDERATION_VALIDATE_COMMUNITY_TIMER))
|
startValidateCommunities(Number(CONFIG.FEDERATION_VALIDATE_COMMUNITY_TIMER))
|
||||||
}
|
}
|
||||||
|
|
||||||
main().catch((e) => {
|
main().catch((e) => {
|
||||||
|
|||||||
@ -31,8 +31,8 @@ const context = {
|
|||||||
|
|
||||||
export const cleanDB = async () => {
|
export const cleanDB = async () => {
|
||||||
// this only works as long we do not have foreign key constraints
|
// this only works as long we do not have foreign key constraints
|
||||||
for (let i = 0; i < entities.length; i++) {
|
for (const entity of entities) {
|
||||||
await resetEntity(entities[i])
|
await resetEntity(entity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,20 +73,20 @@ const run = async () => {
|
|||||||
logger.info('##seed## seeding all random users successful...')
|
logger.info('##seed## seeding all random users successful...')
|
||||||
|
|
||||||
// create GDD
|
// create GDD
|
||||||
for (let i = 0; i < creations.length; i++) {
|
for (const creation of creations) {
|
||||||
await creationFactory(seedClient, creations[i])
|
await creationFactory(seedClient, creation)
|
||||||
}
|
}
|
||||||
logger.info('##seed## seeding all creations successful...')
|
logger.info('##seed## seeding all creations successful...')
|
||||||
|
|
||||||
// create Transaction Links
|
// create Transaction Links
|
||||||
for (let i = 0; i < transactionLinks.length; i++) {
|
for (const transactionLink of transactionLinks) {
|
||||||
await transactionLinkFactory(seedClient, transactionLinks[i])
|
await transactionLinkFactory(seedClient, transactionLink)
|
||||||
}
|
}
|
||||||
logger.info('##seed## seeding all transactionLinks successful...')
|
logger.info('##seed## seeding all transactionLinks successful...')
|
||||||
|
|
||||||
// create Contribution Links
|
// create Contribution Links
|
||||||
for (let i = 0; i < contributionLinks.length; i++) {
|
for (const contributionLink of contributionLinks) {
|
||||||
await contributionLinkFactory(seedClient, contributionLinks[i])
|
await contributionLinkFactory(seedClient, contributionLink)
|
||||||
}
|
}
|
||||||
logger.info('##seed## seeding all contributionLinks successful...')
|
logger.info('##seed## seeding all contributionLinks successful...')
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,11 @@ import { plugins } from './plugins'
|
|||||||
// TODO implement
|
// TODO implement
|
||||||
// import queryComplexity, { simpleEstimator, fieldConfigEstimator } from "graphql-query-complexity";
|
// import queryComplexity, { simpleEstimator, fieldConfigEstimator } from "graphql-query-complexity";
|
||||||
|
|
||||||
type ServerDef = { apollo: ApolloServer; app: Express; con: Connection }
|
interface ServerDef {
|
||||||
|
apollo: ApolloServer
|
||||||
|
app: Express
|
||||||
|
con: Connection
|
||||||
|
}
|
||||||
|
|
||||||
export const createServer = async (
|
export const createServer = async (
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
@ -34,7 +38,7 @@ export const createServer = async (
|
|||||||
|
|
||||||
// open mysql connection
|
// open mysql connection
|
||||||
const con = await connection()
|
const con = await connection()
|
||||||
if (!con || !con.isConnected) {
|
if (!con?.isConnected) {
|
||||||
logger.fatal(`Couldn't open connection to database!`)
|
logger.fatal(`Couldn't open connection to database!`)
|
||||||
throw new Error(`Fatal: Couldn't open connection to database`)
|
throw new Error(`Fatal: Couldn't open connection to database`)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,7 @@ const setHeadersPlugin = {
|
|||||||
return {
|
return {
|
||||||
willSendResponse(requestContext: any) {
|
willSendResponse(requestContext: any) {
|
||||||
const { setHeaders = [] } = requestContext.context
|
const { setHeaders = [] } = requestContext.context
|
||||||
setHeaders.forEach(({ key, value }: { [key: string]: string }) => {
|
setHeaders.forEach(({ key, value }: Record<string, string>) => {
|
||||||
if (requestContext.response.http.headers.get(key)) {
|
if (requestContext.response.http.headers.get(key)) {
|
||||||
requestContext.response.http.headers.set(key, value)
|
requestContext.response.http.headers.set(key, value)
|
||||||
} else {
|
} else {
|
||||||
@ -27,8 +27,8 @@ const setHeadersPlugin = {
|
|||||||
|
|
||||||
const filterVariables = (variables: any) => {
|
const filterVariables = (variables: any) => {
|
||||||
const vars = clonedeep(variables)
|
const vars = clonedeep(variables)
|
||||||
if (vars && vars.password) vars.password = '***'
|
if (vars?.password) vars.password = '***'
|
||||||
if (vars && vars.passwordNew) vars.passwordNew = '***'
|
if (vars?.passwordNew) vars.passwordNew = '***'
|
||||||
return vars
|
return vars
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,10 +14,10 @@ const getDBVersion = async (): Promise<string | null> => {
|
|||||||
|
|
||||||
const checkDBVersion = async (DB_VERSION: string): Promise<boolean> => {
|
const checkDBVersion = async (DB_VERSION: string): Promise<boolean> => {
|
||||||
const dbVersion = await getDBVersion()
|
const dbVersion = await getDBVersion()
|
||||||
if (!dbVersion || dbVersion.indexOf(DB_VERSION) === -1) {
|
if (!dbVersion?.includes(DB_VERSION)) {
|
||||||
logger.error(
|
logger.error(
|
||||||
`Wrong database version detected - the backend requires '${DB_VERSION}' but found '${
|
`Wrong database version detected - the backend requires '${DB_VERSION}' but found '${
|
||||||
dbVersion || 'None'
|
dbVersion ?? 'None'
|
||||||
}`,
|
}`,
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
|
|||||||
@ -11,8 +11,7 @@ export async function retrieveNotRegisteredEmails(): Promise<string[]> {
|
|||||||
}
|
}
|
||||||
const users = await User.find({ relations: ['emailContact'] })
|
const users = await User.find({ relations: ['emailContact'] })
|
||||||
const notRegisteredUser = []
|
const notRegisteredUser = []
|
||||||
for (let i = 0; i < users.length; i++) {
|
for (const user of users) {
|
||||||
const user = users[i]
|
|
||||||
try {
|
try {
|
||||||
await getKlickTippUser(user.emailContact.email)
|
await getKlickTippUser(user.emailContact.email)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { Decimal } from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import i18n from 'i18n'
|
import i18n from 'i18n'
|
||||||
|
|
||||||
export const objectValuesToArray = (obj: { [x: string]: string }): Array<string> => {
|
export const objectValuesToArray = (obj: Record<string, string>): string[] => {
|
||||||
return Object.keys(obj).map(function (key) {
|
return Object.keys(obj).map(function (key) {
|
||||||
return obj[key]
|
return obj[key]
|
||||||
})
|
})
|
||||||
|
|||||||
@ -146,7 +146,7 @@ export const elopageWebhook = async (req: any, res: any): Promise<void> => {
|
|||||||
email,
|
email,
|
||||||
firstName,
|
firstName,
|
||||||
lastName,
|
lastName,
|
||||||
publisherId: loginElopageBuy.publisherId || 0, // This seemed to be the default value if not set
|
publisherId: loginElopageBuy.publisherId ?? 0, // This seemed to be the default value if not set
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
|
|||||||
@ -22,8 +22,8 @@ const context = {
|
|||||||
|
|
||||||
export const cleanDB = async () => {
|
export const cleanDB = async () => {
|
||||||
// this only works as lond we do not have foreign key constraints
|
// this only works as lond we do not have foreign key constraints
|
||||||
for (let i = 0; i < entities.length; i++) {
|
for (const entity of entities) {
|
||||||
await resetEntity(entities[i])
|
await resetEntity(entity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user