mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch 'master' into 2803-open-contribution-edit-button
This commit is contained in:
commit
10022c2247
@ -1,12 +1,27 @@
|
|||||||
|
// eslint-disable-next-line import/no-commonjs, import/unambiguous
|
||||||
module.exports = {
|
module.exports = {
|
||||||
root: true,
|
root: true,
|
||||||
env: {
|
env: {
|
||||||
node: true,
|
node: true,
|
||||||
},
|
},
|
||||||
parser: '@typescript-eslint/parser',
|
parser: '@typescript-eslint/parser',
|
||||||
plugins: ['prettier', '@typescript-eslint', 'type-graphql', 'jest'],
|
plugins: ['prettier', '@typescript-eslint', 'type-graphql', 'jest', 'import'],
|
||||||
extends: ['standard', 'eslint:recommended', 'plugin:prettier/recommended'],
|
extends: [
|
||||||
// add your custom rules here
|
'standard',
|
||||||
|
'eslint:recommended',
|
||||||
|
'plugin:prettier/recommended',
|
||||||
|
'plugin:import/recommended',
|
||||||
|
'plugin:import/typescript',
|
||||||
|
],
|
||||||
|
settings: {
|
||||||
|
'import/parsers': {
|
||||||
|
'@typescript-eslint/parser': ['.ts', '.tsx'],
|
||||||
|
},
|
||||||
|
'import/resolver': {
|
||||||
|
typescript: true,
|
||||||
|
node: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
rules: {
|
rules: {
|
||||||
'no-console': ['error'],
|
'no-console': ['error'],
|
||||||
'no-debugger': 'error',
|
'no-debugger': 'error',
|
||||||
@ -22,6 +37,47 @@ module.exports = {
|
|||||||
'jest/no-identical-title': 'error',
|
'jest/no-identical-title': 'error',
|
||||||
'jest/prefer-to-have-length': 'error',
|
'jest/prefer-to-have-length': 'error',
|
||||||
'jest/valid-expect': 'error',
|
'jest/valid-expect': 'error',
|
||||||
|
// import
|
||||||
|
'import/export': 'error',
|
||||||
|
'import/no-deprecated': 'error',
|
||||||
|
'import/no-empty-named-blocks': 'error',
|
||||||
|
'import/no-extraneous-dependencies': 'error',
|
||||||
|
'import/no-mutable-exports': 'error',
|
||||||
|
'import/no-unused-modules': 'error',
|
||||||
|
'import/no-named-as-default': 'error',
|
||||||
|
'import/no-named-as-default-member': 'error',
|
||||||
|
'import/no-amd': 'error',
|
||||||
|
'import/no-commonjs': 'error',
|
||||||
|
'import/no-import-module-exports': 'error',
|
||||||
|
'import/no-nodejs-modules': 'off',
|
||||||
|
'import/unambiguous': 'error',
|
||||||
|
'import/default': 'error',
|
||||||
|
'import/named': 'error',
|
||||||
|
'import/namespace': 'error',
|
||||||
|
'import/no-absolute-path': 'error',
|
||||||
|
'import/no-cycle': 'off',
|
||||||
|
'import/no-dynamic-require': 'error',
|
||||||
|
'import/no-internal-modules': 'off',
|
||||||
|
'import/no-relative-packages': 'error',
|
||||||
|
'import/no-relative-parent-imports': ['error', { ignore: ['@/*'] }],
|
||||||
|
'import/no-self-import': 'error',
|
||||||
|
'import/no-unresolved': 'error',
|
||||||
|
'import/no-useless-path-segments': 'error',
|
||||||
|
'import/no-webpack-loader-syntax': 'error',
|
||||||
|
'import/consistent-type-specifier-style': 'error',
|
||||||
|
'import/exports-last': 'off',
|
||||||
|
'import/extensions': 'error',
|
||||||
|
'import/first': 'error',
|
||||||
|
'import/group-exports': 'off',
|
||||||
|
'import/newline-after-import': 'error',
|
||||||
|
'import/no-anonymous-default-export': 'error',
|
||||||
|
'import/no-default-export': 'off',
|
||||||
|
'import/no-duplicates': 'error',
|
||||||
|
'import/no-named-default': 'error',
|
||||||
|
'import/no-namespace': 'error',
|
||||||
|
'import/no-unassigned-import': 'error',
|
||||||
|
'import/order': 'error',
|
||||||
|
'import/prefer-default-export': 'off', // TODO
|
||||||
},
|
},
|
||||||
overrides: [
|
overrides: [
|
||||||
// only for ts files
|
// only for ts files
|
||||||
@ -38,9 +94,11 @@ module.exports = {
|
|||||||
'no-void': ['error', { allowAsStatement: true }],
|
'no-void': ['error', { allowAsStatement: true }],
|
||||||
// ignore prefer-regexp-exec rule to allow string.match(regex)
|
// ignore prefer-regexp-exec rule to allow string.match(regex)
|
||||||
'@typescript-eslint/prefer-regexp-exec': 'off',
|
'@typescript-eslint/prefer-regexp-exec': 'off',
|
||||||
|
// this should not run on ts files: https://github.com/import-js/eslint-plugin-import/issues/2215#issuecomment-911245486
|
||||||
|
'import/unambiguous': 'off',
|
||||||
},
|
},
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
tsconfigRootDir: __dirname,
|
tsconfigRootDir: './',
|
||||||
project: ['./tsconfig.json'],
|
project: ['./tsconfig.json'],
|
||||||
// this is to properly reference the referenced project database without requirement of compiling it
|
// this is to properly reference the referenced project database without requirement of compiling it
|
||||||
EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true,
|
EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true,
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
|
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
|
||||||
|
// eslint-disable-next-line import/no-commonjs, import/unambiguous
|
||||||
module.exports = {
|
module.exports = {
|
||||||
verbose: true,
|
verbose: true,
|
||||||
preset: 'ts-jest',
|
preset: 'ts-jest',
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
"clean": "tsc --build --clean",
|
"clean": "tsc --build --clean",
|
||||||
"start": "cross-env TZ=UTC TS_NODE_BASEURL=./build node -r tsconfig-paths/register build/src/index.js",
|
"start": "cross-env TZ=UTC TS_NODE_BASEURL=./build node -r tsconfig-paths/register build/src/index.js",
|
||||||
"dev": "cross-env TZ=UTC nodemon -w src --ext ts --exec ts-node -r tsconfig-paths/register src/index.ts",
|
"dev": "cross-env TZ=UTC nodemon -w src --ext ts --exec ts-node -r tsconfig-paths/register src/index.ts",
|
||||||
"lint": "eslint --max-warnings=0 --ext .js,.ts .",
|
"lint": "eslint --max-warnings=0 .",
|
||||||
"test": "cross-env TZ=UTC NODE_ENV=development jest --runInBand --forceExit --detectOpenHandles",
|
"test": "cross-env TZ=UTC NODE_ENV=development jest --runInBand --forceExit --detectOpenHandles",
|
||||||
"seed": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/seeds/index.ts",
|
"seed": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/seeds/index.ts",
|
||||||
"klicktipp": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/util/klicktipp.ts",
|
"klicktipp": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/util/klicktipp.ts",
|
||||||
@ -29,6 +29,7 @@
|
|||||||
"dotenv": "^10.0.0",
|
"dotenv": "^10.0.0",
|
||||||
"email-templates": "^10.0.1",
|
"email-templates": "^10.0.1",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
|
"gradido-database": "file:../database",
|
||||||
"graphql": "^15.5.1",
|
"graphql": "^15.5.1",
|
||||||
"graphql-request": "5.0.0",
|
"graphql-request": "5.0.0",
|
||||||
"i18n": "^0.15.1",
|
"i18n": "^0.15.1",
|
||||||
@ -61,13 +62,15 @@
|
|||||||
"eslint": "^7.29.0",
|
"eslint": "^7.29.0",
|
||||||
"eslint-config-prettier": "^8.3.0",
|
"eslint-config-prettier": "^8.3.0",
|
||||||
"eslint-config-standard": "^16.0.3",
|
"eslint-config-standard": "^16.0.3",
|
||||||
"eslint-plugin-import": "^2.23.4",
|
"eslint-import-resolver-typescript": "^3.5.3",
|
||||||
|
"eslint-plugin-import": "^2.27.5",
|
||||||
"eslint-plugin-jest": "^27.2.1",
|
"eslint-plugin-jest": "^27.2.1",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"eslint-plugin-prettier": "^3.4.0",
|
"eslint-plugin-prettier": "^3.4.0",
|
||||||
"eslint-plugin-promise": "^5.1.0",
|
"eslint-plugin-promise": "^5.1.0",
|
||||||
"eslint-plugin-type-graphql": "^1.0.0",
|
"eslint-plugin-type-graphql": "^1.0.0",
|
||||||
"faker": "^5.5.3",
|
"faker": "^5.5.3",
|
||||||
|
"graphql-tag": "^2.12.6",
|
||||||
"jest": "^27.2.4",
|
"jest": "^27.2.4",
|
||||||
"klicktipp-api": "^1.0.2",
|
"klicktipp-api": "^1.0.2",
|
||||||
"nodemon": "^2.0.7",
|
"nodemon": "^2.0.7",
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||||
|
// eslint-disable-next-line import/no-relative-parent-imports
|
||||||
import KlicktippConnector from 'klicktipp-api'
|
import KlicktippConnector from 'klicktipp-api'
|
||||||
import CONFIG from '@/config'
|
import CONFIG from '@/config'
|
||||||
|
|
||||||
|
|||||||
@ -1,19 +1,19 @@
|
|||||||
import jwt from 'jsonwebtoken'
|
import { verify, sign } from 'jsonwebtoken'
|
||||||
import CONFIG from '@/config/'
|
|
||||||
import { CustomJwtPayload } from './CustomJwtPayload'
|
import { CustomJwtPayload } from './CustomJwtPayload'
|
||||||
|
import CONFIG from '@/config/'
|
||||||
import LogError from '@/server/LogError'
|
import LogError from '@/server/LogError'
|
||||||
|
|
||||||
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>jwt.verify(token, CONFIG.JWT_SECRET)
|
return <CustomJwtPayload>verify(token, CONFIG.JWT_SECRET)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const encode = (gradidoID: string): string => {
|
export const encode = (gradidoID: string): string => {
|
||||||
const token = jwt.sign({ gradidoID }, CONFIG.JWT_SECRET, {
|
const token = sign({ gradidoID }, CONFIG.JWT_SECRET, {
|
||||||
expiresIn: CONFIG.JWT_EXPIRES_IN,
|
expiresIn: CONFIG.JWT_EXPIRES_IN,
|
||||||
})
|
})
|
||||||
return token
|
return token
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
// ATTENTION: DO NOT PUT ANY SECRETS IN HERE (or the .env)
|
// ATTENTION: DO NOT PUT ANY SECRETS IN HERE (or the .env)
|
||||||
|
|
||||||
import dotenv from 'dotenv'
|
import dotenv from 'dotenv'
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
|
|
||||||
dotenv.config()
|
dotenv.config()
|
||||||
|
|
||||||
Decimal.set({
|
Decimal.set({
|
||||||
@ -10,7 +11,7 @@ Decimal.set({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const constants = {
|
const constants = {
|
||||||
DB_VERSION: '0063-event_link_fields',
|
DB_VERSION: '0064-event_rename',
|
||||||
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
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||||
/* eslint-disable @typescript-eslint/unbound-method */
|
/* eslint-disable @typescript-eslint/unbound-method */
|
||||||
import { createTransport } from 'nodemailer'
|
import { createTransport } from 'nodemailer'
|
||||||
|
import { sendEmailTranslated } from './sendEmailTranslated'
|
||||||
import { logger, i18n } from '@test/testSetup'
|
import { logger, i18n } from '@test/testSetup'
|
||||||
import CONFIG from '@/config'
|
import CONFIG from '@/config'
|
||||||
import { sendEmailTranslated } from './sendEmailTranslated'
|
|
||||||
|
|
||||||
CONFIG.EMAIL = false
|
CONFIG.EMAIL = false
|
||||||
CONFIG.EMAIL_SMTP_URL = 'EMAIL_SMTP_URL'
|
CONFIG.EMAIL_SMTP_URL = 'EMAIL_SMTP_URL'
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
||||||
import CONFIG from '@/config'
|
|
||||||
import { backendLogger as logger } from '@/server/logger'
|
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { createTransport } from 'nodemailer'
|
import { createTransport } from 'nodemailer'
|
||||||
import Email from 'email-templates'
|
import Email from 'email-templates'
|
||||||
import i18n from 'i18n'
|
import i18n from 'i18n'
|
||||||
|
import { backendLogger as logger } from '@/server/logger'
|
||||||
|
import CONFIG from '@/config'
|
||||||
import LogError from '@/server/LogError'
|
import LogError from '@/server/LogError'
|
||||||
|
|
||||||
export const sendEmailTranslated = async (params: {
|
export const sendEmailTranslated = async (params: {
|
||||||
|
|||||||
@ -3,10 +3,7 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { testEnvironment } from '@test/helpers'
|
|
||||||
import { logger, i18n as localization } from '@test/testSetup'
|
|
||||||
import CONFIG from '@/config'
|
|
||||||
import {
|
import {
|
||||||
sendAddedContributionMessageEmail,
|
sendAddedContributionMessageEmail,
|
||||||
sendAccountActivationEmail,
|
sendAccountActivationEmail,
|
||||||
@ -19,6 +16,9 @@ import {
|
|||||||
sendTransactionReceivedEmail,
|
sendTransactionReceivedEmail,
|
||||||
} from './sendEmailVariants'
|
} from './sendEmailVariants'
|
||||||
import { sendEmailTranslated } from './sendEmailTranslated'
|
import { sendEmailTranslated } from './sendEmailTranslated'
|
||||||
|
import { testEnvironment } from '@test/helpers'
|
||||||
|
import { logger, i18n as localization } from '@test/testSetup'
|
||||||
|
import CONFIG from '@/config'
|
||||||
|
|
||||||
let con: any
|
let con: any
|
||||||
let testEnv: any
|
let testEnv: any
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
|
import { sendEmailTranslated } from './sendEmailTranslated'
|
||||||
import CONFIG from '@/config'
|
import CONFIG from '@/config'
|
||||||
import { decimalSeparatorByLanguage } from '@/util/utilities'
|
import { decimalSeparatorByLanguage } from '@/util/utilities'
|
||||||
import { sendEmailTranslated } from './sendEmailTranslated'
|
|
||||||
|
|
||||||
export const sendAddedContributionMessageEmail = (data: {
|
export const sendAddedContributionMessageEmail = (data: {
|
||||||
firstName: string
|
firstName: string
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { User as DbUser } from '@entity/User'
|
import { User as DbUser } from '@entity/User'
|
||||||
import { Contribution as DbContribution } from '@entity/Contribution'
|
import { Contribution as DbContribution } from '@entity/Contribution'
|
||||||
import { Event as DbEvent } from '@entity/Event'
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { User as DbUser } from '@entity/User'
|
import { User as DbUser } from '@entity/User'
|
||||||
import { Contribution as DbContribution } from '@entity/Contribution'
|
import { Contribution as DbContribution } from '@entity/Contribution'
|
||||||
import { Event as DbEvent } from '@entity/Event'
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { User as DbUser } from '@entity/User'
|
import { User as DbUser } from '@entity/User'
|
||||||
import { Contribution as DbContribution } from '@entity/Contribution'
|
import { Contribution as DbContribution } from '@entity/Contribution'
|
||||||
import { Event as DbEvent } from '@entity/Event'
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { User as DbUser } from '@entity/User'
|
import { User as DbUser } from '@entity/User'
|
||||||
import { Contribution as DbContribution } from '@entity/Contribution'
|
import { Contribution as DbContribution } from '@entity/Contribution'
|
||||||
import { Event as DbEvent } from '@entity/Event'
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { User as DbUser } from '@entity/User'
|
import { User as DbUser } from '@entity/User'
|
||||||
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
|
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
|
||||||
import { Event as DbEvent } from '@entity/Event'
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { User as DbUser } from '@entity/User'
|
import { User as DbUser } from '@entity/User'
|
||||||
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
|
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
|
||||||
import { Event as DbEvent } from '@entity/Event'
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { User as DbUser } from '@entity/User'
|
import { User as DbUser } from '@entity/User'
|
||||||
import { Contribution as DbContribution } from '@entity/Contribution'
|
import { Contribution as DbContribution } from '@entity/Contribution'
|
||||||
import { Event as DbEvent } from '@entity/Event'
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
|||||||
6
backend/src/event/EVENT_ADMIN_USER_DELETE.ts
Normal file
6
backend/src/event/EVENT_ADMIN_USER_DELETE.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import { User as DbUser } from '@entity/User'
|
||||||
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
import { Event, EventType } from './Event'
|
||||||
|
|
||||||
|
export const EVENT_ADMIN_USER_DELETE = async (user: DbUser, moderator: DbUser): Promise<DbEvent> =>
|
||||||
|
Event(EventType.ADMIN_USER_DELETE, user, moderator).save()
|
||||||
@ -2,7 +2,7 @@ import { User as DbUser } from '@entity/User'
|
|||||||
import { Event as DbEvent } from '@entity/Event'
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
import { Event, EventType } from './Event'
|
import { Event, EventType } from './Event'
|
||||||
|
|
||||||
export const EVENT_ADMIN_SEND_CONFIRMATION_EMAIL = async (
|
export const EVENT_ADMIN_USER_ROLE_SET = async (
|
||||||
user: DbUser,
|
user: DbUser,
|
||||||
moderator: DbUser,
|
moderator: DbUser,
|
||||||
): Promise<DbEvent> => Event(EventType.ADMIN_SEND_CONFIRMATION_EMAIL, user, moderator).save()
|
): Promise<DbEvent> => Event(EventType.ADMIN_USER_ROLE_SET, user, moderator).save()
|
||||||
8
backend/src/event/EVENT_ADMIN_USER_UNDELETE.ts
Normal file
8
backend/src/event/EVENT_ADMIN_USER_UNDELETE.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { User as DbUser } from '@entity/User'
|
||||||
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
import { Event, EventType } from './Event'
|
||||||
|
|
||||||
|
export const EVENT_ADMIN_USER_UNDELETE = async (
|
||||||
|
user: DbUser,
|
||||||
|
moderator: DbUser,
|
||||||
|
): Promise<DbEvent> => Event(EventType.ADMIN_USER_UNDELETE, user, moderator).save()
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { User as DbUser } from '@entity/User'
|
import { User as DbUser } from '@entity/User'
|
||||||
import { Contribution as DbContribution } from '@entity/Contribution'
|
import { Contribution as DbContribution } from '@entity/Contribution'
|
||||||
import { Event as DbEvent } from '@entity/Event'
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { User as DbUser } from '@entity/User'
|
import { User as DbUser } from '@entity/User'
|
||||||
import { Contribution as DbContribution } from '@entity/Contribution'
|
import { Contribution as DbContribution } from '@entity/Contribution'
|
||||||
import { Event as DbEvent } from '@entity/Event'
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { User as DbUser } from '@entity/User'
|
import { User as DbUser } from '@entity/User'
|
||||||
import { Transaction as DbTransaction } from '@entity/Transaction'
|
import { Transaction as DbTransaction } from '@entity/Transaction'
|
||||||
import { Contribution as DbContribution } from '@entity/Contribution'
|
import { Contribution as DbContribution } from '@entity/Contribution'
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { User as DbUser } from '@entity/User'
|
import { User as DbUser } from '@entity/User'
|
||||||
import { Contribution as DbContribution } from '@entity/Contribution'
|
import { Contribution as DbContribution } from '@entity/Contribution'
|
||||||
import { Event as DbEvent } from '@entity/Event'
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
|||||||
@ -0,0 +1,6 @@
|
|||||||
|
import { User as DbUser } from '@entity/User'
|
||||||
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
import { Event, EventType } from './Event'
|
||||||
|
|
||||||
|
export const EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION = async (user: DbUser): Promise<DbEvent> =>
|
||||||
|
Event(EventType.EMAIL_ACCOUNT_MULTIREGISTRATION, user, { id: 0 } as DbUser).save()
|
||||||
8
backend/src/event/EVENT_EMAIL_ADMIN_CONFIRMATION.ts
Normal file
8
backend/src/event/EVENT_EMAIL_ADMIN_CONFIRMATION.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { User as DbUser } from '@entity/User'
|
||||||
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
import { Event, EventType } from './Event'
|
||||||
|
|
||||||
|
export const EVENT_EMAIL_ADMIN_CONFIRMATION = async (
|
||||||
|
user: DbUser,
|
||||||
|
moderator: DbUser,
|
||||||
|
): Promise<DbEvent> => Event(EventType.EMAIL_ADMIN_CONFIRMATION, user, moderator).save()
|
||||||
6
backend/src/event/EVENT_EMAIL_CONFIRMATION.ts
Normal file
6
backend/src/event/EVENT_EMAIL_CONFIRMATION.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import { User as DbUser } from '@entity/User'
|
||||||
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
import { Event, EventType } from './Event'
|
||||||
|
|
||||||
|
export const EVENT_EMAIL_CONFIRMATION = async (user: DbUser): Promise<DbEvent> =>
|
||||||
|
Event(EventType.EMAIL_CONFIRMATION, user, user).save()
|
||||||
6
backend/src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts
Normal file
6
backend/src/event/EVENT_EMAIL_FORGOT_PASSWORD.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import { User as DbUser } from '@entity/User'
|
||||||
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
import { Event, EventType } from './Event'
|
||||||
|
|
||||||
|
export const EVENT_EMAIL_FORGOT_PASSWORD = async (user: DbUser): Promise<DbEvent> =>
|
||||||
|
Event(EventType.EMAIL_FORGOT_PASSWORD, user, { id: 0 } as DbUser).save()
|
||||||
@ -1,6 +0,0 @@
|
|||||||
import { User as DbUser } from '@entity/User'
|
|
||||||
import { Event as DbEvent } from '@entity/Event'
|
|
||||||
import { Event, EventType } from './Event'
|
|
||||||
|
|
||||||
export const EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL = async (user: DbUser): Promise<DbEvent> =>
|
|
||||||
Event(EventType.SEND_ACCOUNT_MULTIREGISTRATION_EMAIL, user, { id: 0 } as DbUser).save()
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
import { User as DbUser } from '@entity/User'
|
|
||||||
import { Event as DbEvent } from '@entity/Event'
|
|
||||||
import { Event, EventType } from './Event'
|
|
||||||
|
|
||||||
export const EVENT_SEND_CONFIRMATION_EMAIL = async (user: DbUser): Promise<DbEvent> =>
|
|
||||||
Event(EventType.SEND_CONFIRMATION_EMAIL, user, user).save()
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { User as DbUser } from '@entity/User'
|
import { User as DbUser } from '@entity/User'
|
||||||
import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink'
|
import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink'
|
||||||
import { Event as DbEvent } from '@entity/Event'
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { User as DbUser } from '@entity/User'
|
import { User as DbUser } from '@entity/User'
|
||||||
import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink'
|
import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink'
|
||||||
import { Event as DbEvent } from '@entity/Event'
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { User as DbUser } from '@entity/User'
|
import { User as DbUser } from '@entity/User'
|
||||||
import { Transaction as DbTransaction } from '@entity/Transaction'
|
import { Transaction as DbTransaction } from '@entity/Transaction'
|
||||||
import { Event as DbEvent } from '@entity/Event'
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { User as DbUser } from '@entity/User'
|
import { User as DbUser } from '@entity/User'
|
||||||
import { Transaction as DbTransaction } from '@entity/Transaction'
|
import { Transaction as DbTransaction } from '@entity/Transaction'
|
||||||
import { Event as DbEvent } from '@entity/Event'
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
|||||||
6
backend/src/event/EVENT_USER_ACTIVATE_ACCOUNT.ts
Normal file
6
backend/src/event/EVENT_USER_ACTIVATE_ACCOUNT.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import { User as DbUser } from '@entity/User'
|
||||||
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
import { Event, EventType } from './Event'
|
||||||
|
|
||||||
|
export const EVENT_USER_ACTIVATE_ACCOUNT = async (user: DbUser): Promise<DbEvent> =>
|
||||||
|
Event(EventType.USER_ACTIVATE_ACCOUNT, user, user).save()
|
||||||
@ -2,5 +2,5 @@ import { User as DbUser } from '@entity/User'
|
|||||||
import { Event as DbEvent } from '@entity/Event'
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
import { Event, EventType } from './Event'
|
import { Event, EventType } from './Event'
|
||||||
|
|
||||||
export const EVENT_ACTIVATE_ACCOUNT = async (user: DbUser): Promise<DbEvent> =>
|
export const EVENT_USER_INFO_UPDATE = async (user: DbUser): Promise<DbEvent> =>
|
||||||
Event(EventType.ACTIVATE_ACCOUNT, user, user).save()
|
Event(EventType.USER_INFO_UPDATE, user, user).save()
|
||||||
@ -2,5 +2,5 @@ import { User as DbUser } from '@entity/User'
|
|||||||
import { Event as DbEvent } from '@entity/Event'
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
import { Event, EventType } from './Event'
|
import { Event, EventType } from './Event'
|
||||||
|
|
||||||
export const EVENT_LOGIN = async (user: DbUser): Promise<DbEvent> =>
|
export const EVENT_USER_LOGIN = async (user: DbUser): Promise<DbEvent> =>
|
||||||
Event(EventType.LOGIN, user, user).save()
|
Event(EventType.USER_LOGIN, user, user).save()
|
||||||
@ -2,5 +2,5 @@ import { User as DbUser } from '@entity/User'
|
|||||||
import { Event as DbEvent } from '@entity/Event'
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
import { Event, EventType } from './Event'
|
import { Event, EventType } from './Event'
|
||||||
|
|
||||||
export const EVENT_REGISTER = async (user: DbUser): Promise<DbEvent> =>
|
export const EVENT_USER_LOGOUT = async (user: DbUser): Promise<DbEvent> =>
|
||||||
Event(EventType.REGISTER, user, user).save()
|
Event(EventType.USER_LOGOUT, user, user).save()
|
||||||
6
backend/src/event/EVENT_USER_REGISTER.ts
Normal file
6
backend/src/event/EVENT_USER_REGISTER.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import { User as DbUser } from '@entity/User'
|
||||||
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
import { Event, EventType } from './Event'
|
||||||
|
|
||||||
|
export const EVENT_USER_REGISTER = async (user: DbUser): Promise<DbEvent> =>
|
||||||
|
Event(EventType.USER_REGISTER, user, user).save()
|
||||||
@ -5,8 +5,8 @@ import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink'
|
|||||||
import { Contribution as DbContribution } from '@entity/Contribution'
|
import { Contribution as DbContribution } from '@entity/Contribution'
|
||||||
import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage'
|
import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage'
|
||||||
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
|
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { EventType } from './Event'
|
import { EventType } from './EventType'
|
||||||
|
|
||||||
export const Event = (
|
export const Event = (
|
||||||
type: EventType,
|
type: EventType,
|
||||||
@ -34,9 +34,8 @@ export const Event = (
|
|||||||
return event
|
return event
|
||||||
}
|
}
|
||||||
|
|
||||||
export { EventType } from './EventType'
|
export { EventType }
|
||||||
|
|
||||||
export { EVENT_ACTIVATE_ACCOUNT } from './EVENT_ACTIVATE_ACCOUNT'
|
|
||||||
export { EVENT_ADMIN_CONTRIBUTION_CONFIRM } from './EVENT_ADMIN_CONTRIBUTION_CONFIRM'
|
export { EVENT_ADMIN_CONTRIBUTION_CONFIRM } from './EVENT_ADMIN_CONTRIBUTION_CONFIRM'
|
||||||
export { EVENT_ADMIN_CONTRIBUTION_CREATE } from './EVENT_ADMIN_CONTRIBUTION_CREATE'
|
export { EVENT_ADMIN_CONTRIBUTION_CREATE } from './EVENT_ADMIN_CONTRIBUTION_CREATE'
|
||||||
export { EVENT_ADMIN_CONTRIBUTION_DELETE } from './EVENT_ADMIN_CONTRIBUTION_DELETE'
|
export { EVENT_ADMIN_CONTRIBUTION_DELETE } from './EVENT_ADMIN_CONTRIBUTION_DELETE'
|
||||||
@ -46,18 +45,25 @@ export { EVENT_ADMIN_CONTRIBUTION_LINK_CREATE } from './EVENT_ADMIN_CONTRIBUTION
|
|||||||
export { EVENT_ADMIN_CONTRIBUTION_LINK_DELETE } from './EVENT_ADMIN_CONTRIBUTION_LINK_DELETE'
|
export { EVENT_ADMIN_CONTRIBUTION_LINK_DELETE } from './EVENT_ADMIN_CONTRIBUTION_LINK_DELETE'
|
||||||
export { EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE } from './EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE'
|
export { EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE } from './EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE'
|
||||||
export { EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE } from './EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE'
|
export { EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE } from './EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE'
|
||||||
export { EVENT_ADMIN_SEND_CONFIRMATION_EMAIL } from './EVENT_ADMIN_SEND_CONFIRMATION_EMAIL'
|
export { EVENT_ADMIN_USER_DELETE } from './EVENT_ADMIN_USER_DELETE'
|
||||||
|
export { EVENT_ADMIN_USER_UNDELETE } from './EVENT_ADMIN_USER_UNDELETE'
|
||||||
|
export { EVENT_ADMIN_USER_ROLE_SET } from './EVENT_ADMIN_USER_ROLE_SET'
|
||||||
export { EVENT_CONTRIBUTION_CREATE } from './EVENT_CONTRIBUTION_CREATE'
|
export { EVENT_CONTRIBUTION_CREATE } from './EVENT_CONTRIBUTION_CREATE'
|
||||||
export { EVENT_CONTRIBUTION_DELETE } from './EVENT_CONTRIBUTION_DELETE'
|
export { EVENT_CONTRIBUTION_DELETE } from './EVENT_CONTRIBUTION_DELETE'
|
||||||
export { EVENT_CONTRIBUTION_UPDATE } from './EVENT_CONTRIBUTION_UPDATE'
|
export { EVENT_CONTRIBUTION_UPDATE } from './EVENT_CONTRIBUTION_UPDATE'
|
||||||
export { EVENT_CONTRIBUTION_MESSAGE_CREATE } from './EVENT_CONTRIBUTION_MESSAGE_CREATE'
|
export { EVENT_CONTRIBUTION_MESSAGE_CREATE } from './EVENT_CONTRIBUTION_MESSAGE_CREATE'
|
||||||
export { EVENT_CONTRIBUTION_LINK_REDEEM } from './EVENT_CONTRIBUTION_LINK_REDEEM'
|
export { EVENT_CONTRIBUTION_LINK_REDEEM } from './EVENT_CONTRIBUTION_LINK_REDEEM'
|
||||||
export { EVENT_LOGIN } from './EVENT_LOGIN'
|
export { EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION } from './EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION'
|
||||||
export { EVENT_REGISTER } from './EVENT_REGISTER'
|
export { EVENT_EMAIL_ADMIN_CONFIRMATION } from './EVENT_EMAIL_ADMIN_CONFIRMATION'
|
||||||
export { EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL } from './EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL'
|
export { EVENT_EMAIL_CONFIRMATION } from './EVENT_EMAIL_CONFIRMATION'
|
||||||
export { EVENT_SEND_CONFIRMATION_EMAIL } from './EVENT_SEND_CONFIRMATION_EMAIL'
|
export { EVENT_EMAIL_FORGOT_PASSWORD } from './EVENT_EMAIL_FORGOT_PASSWORD'
|
||||||
export { EVENT_TRANSACTION_SEND } from './EVENT_TRANSACTION_SEND'
|
export { EVENT_TRANSACTION_SEND } from './EVENT_TRANSACTION_SEND'
|
||||||
export { EVENT_TRANSACTION_RECEIVE } from './EVENT_TRANSACTION_RECEIVE'
|
export { EVENT_TRANSACTION_RECEIVE } from './EVENT_TRANSACTION_RECEIVE'
|
||||||
export { EVENT_TRANSACTION_LINK_CREATE } from './EVENT_TRANSACTION_LINK_CREATE'
|
export { EVENT_TRANSACTION_LINK_CREATE } from './EVENT_TRANSACTION_LINK_CREATE'
|
||||||
export { EVENT_TRANSACTION_LINK_DELETE } from './EVENT_TRANSACTION_LINK_DELETE'
|
export { EVENT_TRANSACTION_LINK_DELETE } from './EVENT_TRANSACTION_LINK_DELETE'
|
||||||
export { EVENT_TRANSACTION_LINK_REDEEM } from './EVENT_TRANSACTION_LINK_REDEEM'
|
export { EVENT_TRANSACTION_LINK_REDEEM } from './EVENT_TRANSACTION_LINK_REDEEM'
|
||||||
|
export { EVENT_USER_ACTIVATE_ACCOUNT } from './EVENT_USER_ACTIVATE_ACCOUNT'
|
||||||
|
export { EVENT_USER_INFO_UPDATE } from './EVENT_USER_INFO_UPDATE'
|
||||||
|
export { EVENT_USER_LOGIN } from './EVENT_USER_LOGIN'
|
||||||
|
export { EVENT_USER_LOGOUT } from './EVENT_USER_LOGOUT'
|
||||||
|
export { EVENT_USER_REGISTER } from './EVENT_USER_REGISTER'
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
export enum EventType {
|
export enum EventType {
|
||||||
ACTIVATE_ACCOUNT = 'ACTIVATE_ACCOUNT',
|
|
||||||
// TODO CONTRIBUTION_CONFIRM = 'CONTRIBUTION_CONFIRM',
|
// TODO CONTRIBUTION_CONFIRM = 'CONTRIBUTION_CONFIRM',
|
||||||
ADMIN_CONTRIBUTION_CONFIRM = 'ADMIN_CONTRIBUTION_CONFIRM',
|
ADMIN_CONTRIBUTION_CONFIRM = 'ADMIN_CONTRIBUTION_CONFIRM',
|
||||||
ADMIN_CONTRIBUTION_CREATE = 'ADMIN_CONTRIBUTION_CREATE',
|
ADMIN_CONTRIBUTION_CREATE = 'ADMIN_CONTRIBUTION_CREATE',
|
||||||
@ -10,28 +9,34 @@ export enum EventType {
|
|||||||
ADMIN_CONTRIBUTION_LINK_DELETE = 'ADMIN_CONTRIBUTION_LINK_DELETE',
|
ADMIN_CONTRIBUTION_LINK_DELETE = 'ADMIN_CONTRIBUTION_LINK_DELETE',
|
||||||
ADMIN_CONTRIBUTION_LINK_UPDATE = 'ADMIN_CONTRIBUTION_LINK_UPDATE',
|
ADMIN_CONTRIBUTION_LINK_UPDATE = 'ADMIN_CONTRIBUTION_LINK_UPDATE',
|
||||||
ADMIN_CONTRIBUTION_MESSAGE_CREATE = 'ADMIN_CONTRIBUTION_MESSAGE_CREATE',
|
ADMIN_CONTRIBUTION_MESSAGE_CREATE = 'ADMIN_CONTRIBUTION_MESSAGE_CREATE',
|
||||||
ADMIN_SEND_CONFIRMATION_EMAIL = 'ADMIN_SEND_CONFIRMATION_EMAIL',
|
ADMIN_USER_DELETE = 'ADMIN_USER_DELETE',
|
||||||
|
ADMIN_USER_UNDELETE = 'ADMIN_USER_UNDELETE',
|
||||||
|
ADMIN_USER_ROLE_SET = 'ADMIN_USER_ROLE_SET',
|
||||||
CONTRIBUTION_CREATE = 'CONTRIBUTION_CREATE',
|
CONTRIBUTION_CREATE = 'CONTRIBUTION_CREATE',
|
||||||
CONTRIBUTION_DELETE = 'CONTRIBUTION_DELETE',
|
CONTRIBUTION_DELETE = 'CONTRIBUTION_DELETE',
|
||||||
CONTRIBUTION_UPDATE = 'CONTRIBUTION_UPDATE',
|
CONTRIBUTION_UPDATE = 'CONTRIBUTION_UPDATE',
|
||||||
CONTRIBUTION_MESSAGE_CREATE = 'CONTRIBUTION_MESSAGE_CREATE',
|
CONTRIBUTION_MESSAGE_CREATE = 'CONTRIBUTION_MESSAGE_CREATE',
|
||||||
CONTRIBUTION_LINK_REDEEM = 'CONTRIBUTION_LINK_REDEEM',
|
CONTRIBUTION_LINK_REDEEM = 'CONTRIBUTION_LINK_REDEEM',
|
||||||
LOGIN = 'LOGIN',
|
EMAIL_ACCOUNT_MULTIREGISTRATION = 'EMAIL_ACCOUNT_MULTIREGISTRATION',
|
||||||
REGISTER = 'REGISTER',
|
EMAIL_ADMIN_CONFIRMATION = 'EMAIL_ADMIN_CONFIRMATION',
|
||||||
REDEEM_REGISTER = 'REDEEM_REGISTER',
|
EMAIL_CONFIRMATION = 'EMAIL_CONFIRMATION',
|
||||||
SEND_ACCOUNT_MULTIREGISTRATION_EMAIL = 'SEND_ACCOUNT_MULTIREGISTRATION_EMAIL',
|
EMAIL_FORGOT_PASSWORD = 'EMAIL_FORGOT_PASSWORD',
|
||||||
SEND_CONFIRMATION_EMAIL = 'SEND_CONFIRMATION_EMAIL',
|
|
||||||
TRANSACTION_SEND = 'TRANSACTION_SEND',
|
TRANSACTION_SEND = 'TRANSACTION_SEND',
|
||||||
TRANSACTION_RECEIVE = 'TRANSACTION_RECEIVE',
|
TRANSACTION_RECEIVE = 'TRANSACTION_RECEIVE',
|
||||||
TRANSACTION_LINK_CREATE = 'TRANSACTION_LINK_CREATE',
|
TRANSACTION_LINK_CREATE = 'TRANSACTION_LINK_CREATE',
|
||||||
TRANSACTION_LINK_DELETE = 'TRANSACTION_LINK_DELETE',
|
TRANSACTION_LINK_DELETE = 'TRANSACTION_LINK_DELETE',
|
||||||
TRANSACTION_LINK_REDEEM = 'TRANSACTION_LINK_REDEEM',
|
TRANSACTION_LINK_REDEEM = 'TRANSACTION_LINK_REDEEM',
|
||||||
|
USER_ACTIVATE_ACCOUNT = 'ACTIVATE_ACCOUNT',
|
||||||
|
USER_INFO_UPDATE = 'USER_INFO_UPDATE',
|
||||||
|
USER_LOGIN = 'USER_LOGIN',
|
||||||
|
USER_LOGOUT = 'USER_LOGOUT',
|
||||||
|
USER_REGISTER = 'USER_REGISTER',
|
||||||
|
USER_REGISTER_REDEEM = 'USER_REGISTER_REDEEM',
|
||||||
// VISIT_GRADIDO = 'VISIT_GRADIDO',
|
// VISIT_GRADIDO = 'VISIT_GRADIDO',
|
||||||
// VERIFY_REDEEM = 'VERIFY_REDEEM',
|
// VERIFY_REDEEM = 'VERIFY_REDEEM',
|
||||||
// INACTIVE_ACCOUNT = 'INACTIVE_ACCOUNT',
|
// INACTIVE_ACCOUNT = 'INACTIVE_ACCOUNT',
|
||||||
// CONFIRM_EMAIL = 'CONFIRM_EMAIL',
|
// CONFIRM_EMAIL = 'CONFIRM_EMAIL',
|
||||||
// REGISTER_EMAIL_KLICKTIPP = 'REGISTER_EMAIL_KLICKTIPP',
|
// REGISTER_EMAIL_KLICKTIPP = 'REGISTER_EMAIL_KLICKTIPP',
|
||||||
// LOGOUT = 'LOGOUT',
|
|
||||||
// REDEEM_LOGIN = 'REDEEM_LOGIN',
|
// REDEEM_LOGIN = 'REDEEM_LOGIN',
|
||||||
// SEND_FORGOT_PASSWORD_EMAIL = 'SEND_FORGOT_PASSWORD_EMAIL',
|
// SEND_FORGOT_PASSWORD_EMAIL = 'SEND_FORGOT_PASSWORD_EMAIL',
|
||||||
// PASSWORD_CHANGE = 'PASSWORD_CHANGE',
|
// PASSWORD_CHANGE = 'PASSWORD_CHANGE',
|
||||||
|
|||||||
@ -2,9 +2,9 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||||
import { gql } from 'graphql-request'
|
import { gql } from 'graphql-request'
|
||||||
import { backendLogger as logger } from '@/server/logger'
|
|
||||||
import { Community as DbCommunity } from '@entity/Community'
|
import { Community as DbCommunity } from '@entity/Community'
|
||||||
import { GraphQLGetClient } from '../GraphQLGetClient'
|
import { GraphQLGetClient } from '@/federation/client/GraphQLGetClient'
|
||||||
|
import { backendLogger as logger } from '@/server/logger'
|
||||||
import LogError from '@/server/LogError'
|
import LogError from '@/server/LogError'
|
||||||
|
|
||||||
export async function requestGetPublicKey(dbCom: DbCommunity): Promise<string | undefined> {
|
export async function requestGetPublicKey(dbCom: DbCommunity): Promise<string | undefined> {
|
||||||
|
|||||||
@ -2,9 +2,9 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||||
import { gql } from 'graphql-request'
|
import { gql } from 'graphql-request'
|
||||||
import { backendLogger as logger } from '@/server/logger'
|
|
||||||
import { Community as DbCommunity } from '@entity/Community'
|
import { Community as DbCommunity } from '@entity/Community'
|
||||||
import { GraphQLGetClient } from '../GraphQLGetClient'
|
import { GraphQLGetClient } from '@/federation/client/GraphQLGetClient'
|
||||||
|
import { backendLogger as logger } from '@/server/logger'
|
||||||
import LogError from '@/server/LogError'
|
import LogError from '@/server/LogError'
|
||||||
|
|
||||||
export async function requestGetPublicKey(dbCom: DbCommunity): Promise<string | undefined> {
|
export async function requestGetPublicKey(dbCom: DbCommunity): Promise<string | undefined> {
|
||||||
|
|||||||
@ -5,10 +5,10 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||||
|
|
||||||
import { logger } from '@test/testSetup'
|
|
||||||
import { Community as DbCommunity } from '@entity/Community'
|
import { Community as DbCommunity } from '@entity/Community'
|
||||||
import { testEnvironment, cleanDB } from '@test/helpers'
|
|
||||||
import { validateCommunities } from './validateCommunities'
|
import { validateCommunities } from './validateCommunities'
|
||||||
|
import { logger } from '@test/testSetup'
|
||||||
|
import { testEnvironment, cleanDB } from '@test/helpers'
|
||||||
|
|
||||||
let con: any
|
let con: any
|
||||||
let testEnv: any
|
let testEnv: any
|
||||||
|
|||||||
@ -4,8 +4,8 @@ import { IsNull } from '@dbTools/typeorm'
|
|||||||
import { requestGetPublicKey as v1_0_requestGetPublicKey } from './client/1_0/FederationClient'
|
import { requestGetPublicKey as v1_0_requestGetPublicKey } from './client/1_0/FederationClient'
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
import { requestGetPublicKey as v1_1_requestGetPublicKey } from './client/1_1/FederationClient'
|
import { requestGetPublicKey as v1_1_requestGetPublicKey } from './client/1_1/FederationClient'
|
||||||
import { backendLogger as logger } from '@/server/logger'
|
|
||||||
import { ApiVersionType } from './enum/apiVersionType'
|
import { ApiVersionType } from './enum/apiVersionType'
|
||||||
|
import { backendLogger as logger } from '@/server/logger'
|
||||||
import LogError from '@/server/LogError'
|
import LogError from '@/server/LogError'
|
||||||
|
|
||||||
export function startValidateCommunities(timerInterval: number): void {
|
export function startValidateCommunities(timerInterval: number): void {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { ArgsType, Field, InputType } from 'type-graphql'
|
import { ArgsType, Field, InputType } from 'type-graphql'
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
|
|
||||||
@InputType()
|
@InputType()
|
||||||
@ArgsType()
|
@ArgsType()
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { ArgsType, Field, Int } from 'type-graphql'
|
import { ArgsType, Field, Int } from 'type-graphql'
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
|
|
||||||
@ArgsType()
|
@ArgsType()
|
||||||
export default class AdminUpdateContributionArgs {
|
export default class AdminUpdateContributionArgs {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { ArgsType, Field, InputType } from 'type-graphql'
|
import { ArgsType, Field, InputType } from 'type-graphql'
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
|
|
||||||
@InputType()
|
@InputType()
|
||||||
@ArgsType()
|
@ArgsType()
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { ArgsType, Field, Int } from 'type-graphql'
|
import { ArgsType, Field, Int } from 'type-graphql'
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
|
|
||||||
@ArgsType()
|
@ArgsType()
|
||||||
export default class ContributionLinkArgs {
|
export default class ContributionLinkArgs {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { ArgsType, Field } from 'type-graphql'
|
import { ArgsType, Field } from 'type-graphql'
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
|
|
||||||
@ArgsType()
|
@ArgsType()
|
||||||
export default class TransactionLinkArgs {
|
export default class TransactionLinkArgs {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { ArgsType, Field } from 'type-graphql'
|
import { ArgsType, Field } from 'type-graphql'
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
|
|
||||||
@ArgsType()
|
@ArgsType()
|
||||||
export default class TransactionSendArgs {
|
export default class TransactionSendArgs {
|
||||||
|
|||||||
@ -4,11 +4,11 @@
|
|||||||
|
|
||||||
import { AuthChecker } from 'type-graphql'
|
import { AuthChecker } from 'type-graphql'
|
||||||
|
|
||||||
|
import { User } from '@entity/User'
|
||||||
import { decode, encode } from '@/auth/JWT'
|
import { decode, encode } from '@/auth/JWT'
|
||||||
import { ROLE_UNAUTHORIZED, ROLE_USER, ROLE_ADMIN } from '@/auth/ROLES'
|
import { ROLE_UNAUTHORIZED, ROLE_USER, ROLE_ADMIN } from '@/auth/ROLES'
|
||||||
import { RIGHTS } from '@/auth/RIGHTS'
|
import { RIGHTS } from '@/auth/RIGHTS'
|
||||||
import { INALIENABLE_RIGHTS } from '@/auth/INALIENABLE_RIGHTS'
|
import { INALIENABLE_RIGHTS } from '@/auth/INALIENABLE_RIGHTS'
|
||||||
import { User } from '@entity/User'
|
|
||||||
import LogError from '@/server/LogError'
|
import LogError from '@/server/LogError'
|
||||||
|
|
||||||
const isAuthorized: AuthChecker<any> = async ({ context }, rights) => {
|
const isAuthorized: AuthChecker<any> = async ({ context }, rights) => {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { ObjectType, Field } from 'type-graphql'
|
import { ObjectType, Field } from 'type-graphql'
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
|
|
||||||
@ObjectType()
|
@ObjectType()
|
||||||
export class AdminUpdateContribution {
|
export class AdminUpdateContribution {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { ObjectType, Field, Int, Float } from 'type-graphql'
|
import { ObjectType, Field, Int, Float } from 'type-graphql'
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
|
|
||||||
@ObjectType()
|
@ObjectType()
|
||||||
export class Balance {
|
export class Balance {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { ObjectType, Field, Int } from 'type-graphql'
|
import { ObjectType, Field, Int } from 'type-graphql'
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
|
|
||||||
@ObjectType()
|
@ObjectType()
|
||||||
export class DynamicStatisticsFields {
|
export class DynamicStatisticsFields {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { ObjectType, Field, Int } from 'type-graphql'
|
import { ObjectType, Field, Int } from 'type-graphql'
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { Contribution as dbContribution } from '@entity/Contribution'
|
import { Contribution as dbContribution } from '@entity/Contribution'
|
||||||
import { User } from '@entity/User'
|
import { User } from '@entity/User'
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { ObjectType, Field, Int } from 'type-graphql'
|
import { ObjectType, Field, Int } from 'type-graphql'
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { ContributionLink as dbContributionLink } from '@entity/ContributionLink'
|
import { ContributionLink as dbContributionLink } from '@entity/ContributionLink'
|
||||||
import CONFIG from '@/config'
|
import CONFIG from '@/config'
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { ObjectType, Field, Int } from 'type-graphql'
|
import { ObjectType, Field, Int } from 'type-graphql'
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
|
|
||||||
interface DecayInterface {
|
interface DecayInterface {
|
||||||
balance: Decimal
|
balance: Decimal
|
||||||
|
|||||||
@ -3,8 +3,8 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||||
import { GdtEntry } from './GdtEntry'
|
|
||||||
import { ObjectType, Field, Int, Float } from 'type-graphql'
|
import { ObjectType, Field, Int, Float } from 'type-graphql'
|
||||||
|
import { GdtEntry } from './GdtEntry'
|
||||||
|
|
||||||
@ObjectType()
|
@ObjectType()
|
||||||
export class GdtEntryList {
|
export class GdtEntryList {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { ObjectType, Field, Int } from 'type-graphql'
|
import { ObjectType, Field, Int } from 'type-graphql'
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
|
|
||||||
@ObjectType()
|
@ObjectType()
|
||||||
export class OpenCreation {
|
export class OpenCreation {
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import { ObjectType, Field, Int } from 'type-graphql'
|
import { ObjectType, Field, Int } from 'type-graphql'
|
||||||
import { Decay } from './Decay'
|
|
||||||
import { Transaction as dbTransaction } from '@entity/Transaction'
|
import { Transaction as dbTransaction } from '@entity/Transaction'
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { TransactionTypeId } from '@enum/TransactionTypeId'
|
import { Decay } from './Decay'
|
||||||
import { User } from './User'
|
import { User } from './User'
|
||||||
|
import { TransactionTypeId } from '@enum/TransactionTypeId'
|
||||||
|
|
||||||
@ObjectType()
|
@ObjectType()
|
||||||
export class Transaction {
|
export class Transaction {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { ObjectType, Field, Int } from 'type-graphql'
|
import { ObjectType, Field, Int } from 'type-graphql'
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink'
|
import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink'
|
||||||
import { User } from './User'
|
import { User } from './User'
|
||||||
import CONFIG from '@/config'
|
import CONFIG from '@/config'
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { ObjectType, Field, Int } from 'type-graphql'
|
import { ObjectType, Field, Int } from 'type-graphql'
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { Contribution } from '@entity/Contribution'
|
import { Contribution } from '@entity/Contribution'
|
||||||
import { User } from '@entity/User'
|
import { User } from '@entity/User'
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { ObjectType, Field, Int } from 'type-graphql'
|
import { ObjectType, Field, Int } from 'type-graphql'
|
||||||
import { KlickTipp } from './KlickTipp'
|
|
||||||
import { User as dbUser } from '@entity/User'
|
import { User as dbUser } from '@entity/User'
|
||||||
|
import { KlickTipp } from './KlickTipp'
|
||||||
import { UserContact } from './UserContact'
|
import { UserContact } from './UserContact'
|
||||||
|
|
||||||
@ObjectType()
|
@ObjectType()
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { ObjectType, Field, Int } from 'type-graphql'
|
import { ObjectType, Field, Int } from 'type-graphql'
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { User } from '@entity/User'
|
import { User } from '@entity/User'
|
||||||
|
|
||||||
@ObjectType()
|
@ObjectType()
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { Resolver, Query, Ctx, Authorized } from 'type-graphql'
|
import { Resolver, Query, Ctx, Authorized } from 'type-graphql'
|
||||||
import { getCustomRepository } from '@dbTools/typeorm'
|
import { getCustomRepository } from '@dbTools/typeorm'
|
||||||
|
|
||||||
import { Transaction as dbTransaction } from '@entity/Transaction'
|
import { Transaction as dbTransaction } from '@entity/Transaction'
|
||||||
import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink'
|
import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink'
|
||||||
|
|
||||||
|
import { GdtResolver } from './GdtResolver'
|
||||||
|
import { getLastTransaction } from './util/getLastTransaction'
|
||||||
import { TransactionLinkRepository } from '@repository/TransactionLink'
|
import { TransactionLinkRepository } from '@repository/TransactionLink'
|
||||||
|
|
||||||
import { Balance } from '@model/Balance'
|
import { Balance } from '@model/Balance'
|
||||||
@ -14,9 +16,6 @@ import { backendLogger as logger } from '@/server/logger'
|
|||||||
import { Context, getUser } from '@/server/context'
|
import { Context, getUser } from '@/server/context'
|
||||||
import { calculateDecay } from '@/util/decay'
|
import { calculateDecay } from '@/util/decay'
|
||||||
import { RIGHTS } from '@/auth/RIGHTS'
|
import { RIGHTS } from '@/auth/RIGHTS'
|
||||||
import { GdtResolver } from './GdtResolver'
|
|
||||||
|
|
||||||
import { getLastTransaction } from './util/getLastTransaction'
|
|
||||||
|
|
||||||
@Resolver()
|
@Resolver()
|
||||||
export class BalanceResolver {
|
export class BalanceResolver {
|
||||||
|
|||||||
@ -5,8 +5,8 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||||
|
|
||||||
import { getCommunities } from '@/seeds/graphql/queries'
|
|
||||||
import { Community as DbCommunity } from '@entity/Community'
|
import { Community as DbCommunity } from '@entity/Community'
|
||||||
|
import { getCommunities } from '@/seeds/graphql/queries'
|
||||||
import { testEnvironment } from '@test/helpers'
|
import { testEnvironment } from '@test/helpers'
|
||||||
|
|
||||||
let query: any
|
let query: any
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { Resolver, Query, Authorized } from 'type-graphql'
|
import { Resolver, Query, Authorized } from 'type-graphql'
|
||||||
|
|
||||||
import { Community } from '@model/Community'
|
|
||||||
import { Community as DbCommunity } from '@entity/Community'
|
import { Community as DbCommunity } from '@entity/Community'
|
||||||
|
import { Community } from '@model/Community'
|
||||||
|
|
||||||
import { RIGHTS } from '@/auth/RIGHTS'
|
import { RIGHTS } from '@/auth/RIGHTS'
|
||||||
|
|
||||||
|
|||||||
@ -4,9 +4,11 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { logger } from '@test/testSetup'
|
|
||||||
import { GraphQLError } from 'graphql'
|
import { GraphQLError } from 'graphql'
|
||||||
|
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
|
||||||
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
import { logger } from '@test/testSetup'
|
||||||
import {
|
import {
|
||||||
login,
|
login,
|
||||||
createContributionLink,
|
createContributionLink,
|
||||||
@ -18,9 +20,7 @@ import { cleanDB, testEnvironment, resetToken } from '@test/helpers'
|
|||||||
import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
|
import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
|
||||||
import { peterLustig } from '@/seeds/users/peter-lustig'
|
import { peterLustig } from '@/seeds/users/peter-lustig'
|
||||||
import { userFactory } from '@/seeds/factory/user'
|
import { userFactory } from '@/seeds/factory/user'
|
||||||
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
|
|
||||||
import { EventType } from '@/event/Event'
|
import { EventType } from '@/event/Event'
|
||||||
import { Event as DbEvent } from '@entity/Event'
|
|
||||||
|
|
||||||
let mutate: any, query: any, con: any
|
let mutate: any, query: any, con: any
|
||||||
let testEnv: any
|
let testEnv: any
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { Resolver, Args, Arg, Authorized, Mutation, Query, Int, Ctx } from 'type-graphql'
|
import { Resolver, Args, Arg, Authorized, Mutation, Query, Int, Ctx } from 'type-graphql'
|
||||||
import { MoreThan, IsNull } from '@dbTools/typeorm'
|
import { MoreThan, IsNull } from '@dbTools/typeorm'
|
||||||
|
|
||||||
|
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
|
||||||
import {
|
import {
|
||||||
CONTRIBUTIONLINK_NAME_MAX_CHARS,
|
CONTRIBUTIONLINK_NAME_MAX_CHARS,
|
||||||
CONTRIBUTIONLINK_NAME_MIN_CHARS,
|
CONTRIBUTIONLINK_NAME_MIN_CHARS,
|
||||||
@ -9,16 +10,15 @@ import {
|
|||||||
MEMO_MIN_CHARS,
|
MEMO_MIN_CHARS,
|
||||||
} from './const/const'
|
} from './const/const'
|
||||||
import { isStartEndDateValid } from './util/creations'
|
import { isStartEndDateValid } from './util/creations'
|
||||||
|
import { transactionLinkCode as contributionLinkCode } from './TransactionLinkResolver'
|
||||||
import { ContributionLinkList } from '@model/ContributionLinkList'
|
import { ContributionLinkList } from '@model/ContributionLinkList'
|
||||||
import { ContributionLink } from '@model/ContributionLink'
|
import { ContributionLink } from '@model/ContributionLink'
|
||||||
import ContributionLinkArgs from '@arg/ContributionLinkArgs'
|
import ContributionLinkArgs from '@arg/ContributionLinkArgs'
|
||||||
import { RIGHTS } from '@/auth/RIGHTS'
|
import { RIGHTS } from '@/auth/RIGHTS'
|
||||||
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
|
|
||||||
import { Order } from '@enum/Order'
|
import { Order } from '@enum/Order'
|
||||||
import Paginated from '@arg/Paginated'
|
import Paginated from '@arg/Paginated'
|
||||||
|
|
||||||
// TODO: this is a strange construct
|
// TODO: this is a strange construct
|
||||||
import { transactionLinkCode as contributionLinkCode } from './TransactionLinkResolver'
|
|
||||||
import LogError from '@/server/LogError'
|
import LogError from '@/server/LogError'
|
||||||
import { Context, getUser } from '@/server/context'
|
import { Context, getUser } from '@/server/context'
|
||||||
import {
|
import {
|
||||||
|
|||||||
@ -6,9 +6,10 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||||
|
|
||||||
|
import { GraphQLError } from 'graphql'
|
||||||
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
import { cleanDB, resetToken, testEnvironment } from '@test/helpers'
|
import { cleanDB, resetToken, testEnvironment } from '@test/helpers'
|
||||||
import { logger, i18n as localization } from '@test/testSetup'
|
import { logger, i18n as localization } from '@test/testSetup'
|
||||||
import { GraphQLError } from 'graphql'
|
|
||||||
import {
|
import {
|
||||||
adminCreateContributionMessage,
|
adminCreateContributionMessage,
|
||||||
createContribution,
|
createContribution,
|
||||||
@ -21,7 +22,6 @@ import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
|
|||||||
import { peterLustig } from '@/seeds/users/peter-lustig'
|
import { peterLustig } from '@/seeds/users/peter-lustig'
|
||||||
import { sendAddedContributionMessageEmail } from '@/emails/sendEmailVariants'
|
import { sendAddedContributionMessageEmail } from '@/emails/sendEmailVariants'
|
||||||
import { EventType } from '@/event/Event'
|
import { EventType } from '@/event/Event'
|
||||||
import { Event as DbEvent } from '@entity/Event'
|
|
||||||
|
|
||||||
jest.mock('@/emails/sendEmailVariants', () => {
|
jest.mock('@/emails/sendEmailVariants', () => {
|
||||||
const originalModule = jest.requireActual('@/emails/sendEmailVariants')
|
const originalModule = jest.requireActual('@/emails/sendEmailVariants')
|
||||||
|
|||||||
@ -6,7 +6,13 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||||
|
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
|
import { GraphQLError } from 'graphql'
|
||||||
|
import { Contribution } from '@entity/Contribution'
|
||||||
|
import { Transaction as DbTransaction } from '@entity/Transaction'
|
||||||
|
import { User } from '@entity/User'
|
||||||
|
import { UserInputError } from 'apollo-server-express'
|
||||||
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
|
import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
|
||||||
import { bobBaumeister } from '@/seeds/users/bob-baumeister'
|
import { bobBaumeister } from '@/seeds/users/bob-baumeister'
|
||||||
import { stephenHawking } from '@/seeds/users/stephen-hawking'
|
import { stephenHawking } from '@/seeds/users/stephen-hawking'
|
||||||
@ -41,18 +47,12 @@ import {
|
|||||||
contributionDateFormatter,
|
contributionDateFormatter,
|
||||||
resetEntity,
|
resetEntity,
|
||||||
} from '@test/helpers'
|
} from '@test/helpers'
|
||||||
import { GraphQLError } from 'graphql'
|
|
||||||
import { userFactory } from '@/seeds/factory/user'
|
import { userFactory } from '@/seeds/factory/user'
|
||||||
import { creationFactory } from '@/seeds/factory/creation'
|
import { creationFactory } from '@/seeds/factory/creation'
|
||||||
import { creations } from '@/seeds/creation/index'
|
import { creations } from '@/seeds/creation/index'
|
||||||
import { peterLustig } from '@/seeds/users/peter-lustig'
|
import { peterLustig } from '@/seeds/users/peter-lustig'
|
||||||
import { Event as DbEvent } from '@entity/Event'
|
|
||||||
import { Contribution } from '@entity/Contribution'
|
|
||||||
import { Transaction as DbTransaction } from '@entity/Transaction'
|
|
||||||
import { User } from '@entity/User'
|
|
||||||
import { EventType } from '@/event/Event'
|
import { EventType } from '@/event/Event'
|
||||||
import { logger, i18n as localization } from '@test/testSetup'
|
import { logger, i18n as localization } from '@test/testSetup'
|
||||||
import { UserInputError } from 'apollo-server-express'
|
|
||||||
import { raeuberHotzenplotz } from '@/seeds/users/raeuber-hotzenplotz'
|
import { raeuberHotzenplotz } from '@/seeds/users/raeuber-hotzenplotz'
|
||||||
import { UnconfirmedContribution } from '@model/UnconfirmedContribution'
|
import { UnconfirmedContribution } from '@model/UnconfirmedContribution'
|
||||||
import { ContributionListResult } from '@model/Contribution'
|
import { ContributionListResult } from '@model/Contribution'
|
||||||
@ -2483,10 +2483,10 @@ describe('ContributionResolver', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('stores the SEND_CONFIRMATION_EMAIL event in the database', async () => {
|
it('stores the EMAIL_CONFIRMATION event in the database', async () => {
|
||||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
type: EventType.SEND_CONFIRMATION_EMAIL,
|
type: EventType.EMAIL_CONFIRMATION,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { Arg, Args, Authorized, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql'
|
import { Arg, Args, Authorized, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql'
|
||||||
import { IsNull, getConnection } from '@dbTools/typeorm'
|
import { IsNull, getConnection } from '@dbTools/typeorm'
|
||||||
|
|
||||||
@ -9,6 +9,16 @@ import { UserContact } from '@entity/UserContact'
|
|||||||
import { User as DbUser } from '@entity/User'
|
import { User as DbUser } from '@entity/User'
|
||||||
import { Transaction as DbTransaction } from '@entity/Transaction'
|
import { Transaction as DbTransaction } from '@entity/Transaction'
|
||||||
|
|
||||||
|
import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const'
|
||||||
|
import { getLastTransaction } from './util/getLastTransaction'
|
||||||
|
import { findContributions } from './util/findContributions'
|
||||||
|
import {
|
||||||
|
getUserCreation,
|
||||||
|
validateContribution,
|
||||||
|
updateCreations,
|
||||||
|
isValidDateString,
|
||||||
|
getOpenCreations,
|
||||||
|
} from './util/creations'
|
||||||
import { AdminUpdateContribution } from '@model/AdminUpdateContribution'
|
import { AdminUpdateContribution } from '@model/AdminUpdateContribution'
|
||||||
import { Contribution, ContributionListResult } from '@model/Contribution'
|
import { Contribution, ContributionListResult } from '@model/Contribution'
|
||||||
import { Decay } from '@model/Decay'
|
import { Decay } from '@model/Decay'
|
||||||
@ -27,14 +37,6 @@ import AdminUpdateContributionArgs from '@arg/AdminUpdateContributionArgs'
|
|||||||
import { RIGHTS } from '@/auth/RIGHTS'
|
import { RIGHTS } from '@/auth/RIGHTS'
|
||||||
import { Context, getUser, getClientTimezoneOffset } from '@/server/context'
|
import { Context, getUser, getClientTimezoneOffset } from '@/server/context'
|
||||||
import { backendLogger as logger } from '@/server/logger'
|
import { backendLogger as logger } from '@/server/logger'
|
||||||
import {
|
|
||||||
getUserCreation,
|
|
||||||
validateContribution,
|
|
||||||
updateCreations,
|
|
||||||
isValidDateString,
|
|
||||||
getOpenCreations,
|
|
||||||
} from './util/creations'
|
|
||||||
import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const'
|
|
||||||
import {
|
import {
|
||||||
EVENT_CONTRIBUTION_CREATE,
|
EVENT_CONTRIBUTION_CREATE,
|
||||||
EVENT_CONTRIBUTION_DELETE,
|
EVENT_CONTRIBUTION_DELETE,
|
||||||
@ -54,9 +56,6 @@ import {
|
|||||||
import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK'
|
import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK'
|
||||||
import LogError from '@/server/LogError'
|
import LogError from '@/server/LogError'
|
||||||
|
|
||||||
import { getLastTransaction } from './util/getLastTransaction'
|
|
||||||
import { findContributions } from './util/findContributions'
|
|
||||||
|
|
||||||
@Resolver()
|
@Resolver()
|
||||||
export class ContributionResolver {
|
export class ContributionResolver {
|
||||||
@Authorized([RIGHTS.CREATE_CONTRIBUTION])
|
@Authorized([RIGHTS.CREATE_CONTRIBUTION])
|
||||||
|
|||||||
@ -4,12 +4,12 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||||
|
|
||||||
import { testEnvironment, cleanDB } from '@test/helpers'
|
|
||||||
import { User as DbUser } from '@entity/User'
|
import { User as DbUser } from '@entity/User'
|
||||||
|
import { GraphQLError } from 'graphql'
|
||||||
|
import { testEnvironment, cleanDB } from '@test/helpers'
|
||||||
import { createUser, setPassword, forgotPassword } from '@/seeds/graphql/mutations'
|
import { createUser, setPassword, forgotPassword } from '@/seeds/graphql/mutations'
|
||||||
import { queryOptIn } from '@/seeds/graphql/queries'
|
import { queryOptIn } from '@/seeds/graphql/queries'
|
||||||
import CONFIG from '@/config'
|
import CONFIG from '@/config'
|
||||||
import { GraphQLError } from 'graphql'
|
|
||||||
|
|
||||||
let mutate: any, query: any, con: any
|
let mutate: any, query: any, con: any
|
||||||
let testEnv: any
|
let testEnv: any
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { Resolver, Query, Authorized, FieldResolver } from 'type-graphql'
|
import { Resolver, Query, Authorized, FieldResolver } from 'type-graphql'
|
||||||
import { getConnection } from '@dbTools/typeorm'
|
import { getConnection } from '@dbTools/typeorm'
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,13 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||||
|
|
||||||
|
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
|
||||||
|
import { User } from '@entity/User'
|
||||||
|
import { Decimal } from 'decimal.js-light'
|
||||||
|
import { GraphQLError } from 'graphql'
|
||||||
|
import { Transaction } from '@entity/Transaction'
|
||||||
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
import { UserContact } from '@entity/UserContact'
|
||||||
import { transactionLinkCode } from './TransactionLinkResolver'
|
import { transactionLinkCode } from './TransactionLinkResolver'
|
||||||
import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
|
import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
|
||||||
import { peterLustig } from '@/seeds/users/peter-lustig'
|
import { peterLustig } from '@/seeds/users/peter-lustig'
|
||||||
@ -22,20 +29,14 @@ import {
|
|||||||
createContribution,
|
createContribution,
|
||||||
updateContribution,
|
updateContribution,
|
||||||
createTransactionLink,
|
createTransactionLink,
|
||||||
|
deleteTransactionLink,
|
||||||
confirmContribution,
|
confirmContribution,
|
||||||
} from '@/seeds/graphql/mutations'
|
} from '@/seeds/graphql/mutations'
|
||||||
import { listTransactionLinksAdmin } from '@/seeds/graphql/queries'
|
import { listTransactionLinksAdmin } from '@/seeds/graphql/queries'
|
||||||
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
|
|
||||||
import { User } from '@entity/User'
|
|
||||||
import { Transaction } from '@entity/Transaction'
|
|
||||||
import { UnconfirmedContribution } from '@model/UnconfirmedContribution'
|
import { UnconfirmedContribution } from '@model/UnconfirmedContribution'
|
||||||
import Decimal from 'decimal.js-light'
|
|
||||||
import { GraphQLError } from 'graphql'
|
|
||||||
import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK'
|
import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK'
|
||||||
import { logger } from '@test/testSetup'
|
import { logger } from '@test/testSetup'
|
||||||
import { EventType } from '@/event/Event'
|
import { EventType } from '@/event/Event'
|
||||||
import { Event as DbEvent } from '@entity/Event'
|
|
||||||
import { UserContact } from '@entity/UserContact'
|
|
||||||
|
|
||||||
// mock semaphore to allow use fake timers
|
// mock semaphore to allow use fake timers
|
||||||
jest.mock('@/util/TRANSACTIONS_LOCK')
|
jest.mock('@/util/TRANSACTIONS_LOCK')
|
||||||
@ -573,6 +574,7 @@ describe('TransactionLinkResolver', () => {
|
|||||||
|
|
||||||
describe('link exists', () => {
|
describe('link exists', () => {
|
||||||
let myCode: string
|
let myCode: string
|
||||||
|
let myId: number
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await mutate({
|
await mutate({
|
||||||
@ -589,7 +591,7 @@ describe('TransactionLinkResolver', () => {
|
|||||||
})
|
})
|
||||||
const {
|
const {
|
||||||
data: {
|
data: {
|
||||||
createTransactionLink: { code },
|
createTransactionLink: { id, code },
|
||||||
},
|
},
|
||||||
} = await mutate({
|
} = await mutate({
|
||||||
mutation: createTransactionLink,
|
mutation: createTransactionLink,
|
||||||
@ -599,6 +601,23 @@ describe('TransactionLinkResolver', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
myCode = code
|
myCode = code
|
||||||
|
myId = id
|
||||||
|
})
|
||||||
|
|
||||||
|
it('stores the TRANSACTION_LINK_CREATE event in the database', async () => {
|
||||||
|
const userConatct = await UserContact.findOneOrFail(
|
||||||
|
{ email: 'bibi@bloxberg.de' },
|
||||||
|
{ relations: ['user'] },
|
||||||
|
)
|
||||||
|
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
type: EventType.TRANSACTION_LINK_CREATE,
|
||||||
|
affectedUserId: userConatct.user.id,
|
||||||
|
actingUserId: userConatct.user.id,
|
||||||
|
involvedTransactionLinkId: myId,
|
||||||
|
amount: expect.decimalEqual(200),
|
||||||
|
}),
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('own link', () => {
|
describe('own link', () => {
|
||||||
@ -625,6 +644,94 @@ describe('TransactionLinkResolver', () => {
|
|||||||
expect.any(Number),
|
expect.any(Number),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
it('delete own link', async () => {
|
||||||
|
await expect(
|
||||||
|
mutate({
|
||||||
|
mutation: deleteTransactionLink,
|
||||||
|
variables: {
|
||||||
|
id: myId,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
).resolves.toMatchObject({
|
||||||
|
data: { deleteTransactionLink: true },
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('stores the TRANSACTION_LINK_DELETE event in the database', async () => {
|
||||||
|
const userConatct = await UserContact.findOneOrFail(
|
||||||
|
{ email: 'bibi@bloxberg.de' },
|
||||||
|
{ relations: ['user'] },
|
||||||
|
)
|
||||||
|
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
type: EventType.TRANSACTION_LINK_DELETE,
|
||||||
|
affectedUserId: userConatct.user.id,
|
||||||
|
actingUserId: userConatct.user.id,
|
||||||
|
involvedTransactionLinkId: myId,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('other link', () => {
|
||||||
|
beforeAll(async () => {
|
||||||
|
await mutate({
|
||||||
|
mutation: login,
|
||||||
|
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||||
|
})
|
||||||
|
const {
|
||||||
|
data: {
|
||||||
|
createTransactionLink: { id, code },
|
||||||
|
},
|
||||||
|
} = await mutate({
|
||||||
|
mutation: createTransactionLink,
|
||||||
|
variables: {
|
||||||
|
amount: 200,
|
||||||
|
memo: 'This is a transaction link from bibi',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
myCode = code
|
||||||
|
myId = id
|
||||||
|
await mutate({
|
||||||
|
mutation: login,
|
||||||
|
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('successfully redeems link', async () => {
|
||||||
|
await expect(
|
||||||
|
mutate({
|
||||||
|
mutation: redeemTransactionLink,
|
||||||
|
variables: {
|
||||||
|
code: myCode,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
).resolves.toMatchObject({
|
||||||
|
data: { redeemTransactionLink: true },
|
||||||
|
errors: undefined,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('stores the TRANSACTION_LINK_REDEEM event in the database', async () => {
|
||||||
|
const creator = await UserContact.findOneOrFail(
|
||||||
|
{ email: 'bibi@bloxberg.de' },
|
||||||
|
{ relations: ['user'] },
|
||||||
|
)
|
||||||
|
const redeemer = await UserContact.findOneOrFail(
|
||||||
|
{ email: 'peter@lustig.de' },
|
||||||
|
{ relations: ['user'] },
|
||||||
|
)
|
||||||
|
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
type: EventType.TRANSACTION_LINK_REDEEM,
|
||||||
|
affectedUserId: redeemer.user.id,
|
||||||
|
actingUserId: redeemer.user.id,
|
||||||
|
involvedUserId: creator.user.id,
|
||||||
|
involvedTransactionLinkId: myId,
|
||||||
|
amount: expect.decimalEqual(200),
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { randomBytes } from 'crypto'
|
import { randomBytes } from 'crypto'
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
|
|
||||||
import { getConnection } from '@dbTools/typeorm'
|
import { getConnection } from '@dbTools/typeorm'
|
||||||
|
|
||||||
@ -9,6 +9,11 @@ import { Transaction as DbTransaction } from '@entity/Transaction'
|
|||||||
import { Contribution as DbContribution } from '@entity/Contribution'
|
import { Contribution as DbContribution } from '@entity/Contribution'
|
||||||
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
|
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
|
||||||
|
|
||||||
|
import { Resolver, Args, Arg, Authorized, Ctx, Mutation, Query, Int } from 'type-graphql'
|
||||||
|
import { getUserCreation, validateContribution } from './util/creations'
|
||||||
|
import { executeTransaction } from './TransactionResolver'
|
||||||
|
import { getLastTransaction } from './util/getLastTransaction'
|
||||||
|
import transactionLinkList from './util/transactionLinkList'
|
||||||
import { User } from '@model/User'
|
import { User } from '@model/User'
|
||||||
import { ContributionLink } from '@model/ContributionLink'
|
import { ContributionLink } from '@model/ContributionLink'
|
||||||
import { Decay } from '@model/Decay'
|
import { Decay } from '@model/Decay'
|
||||||
@ -20,21 +25,14 @@ import { ContributionCycleType } from '@enum/ContributionCycleType'
|
|||||||
import TransactionLinkArgs from '@arg/TransactionLinkArgs'
|
import TransactionLinkArgs from '@arg/TransactionLinkArgs'
|
||||||
import Paginated from '@arg/Paginated'
|
import Paginated from '@arg/Paginated'
|
||||||
import TransactionLinkFilters from '@arg/TransactionLinkFilters'
|
import TransactionLinkFilters from '@arg/TransactionLinkFilters'
|
||||||
|
|
||||||
import { backendLogger as logger } from '@/server/logger'
|
import { backendLogger as logger } from '@/server/logger'
|
||||||
import { Context, getUser, getClientTimezoneOffset } from '@/server/context'
|
import { Context, getUser, getClientTimezoneOffset } from '@/server/context'
|
||||||
import { Resolver, Args, Arg, Authorized, Ctx, Mutation, Query, Int } from 'type-graphql'
|
|
||||||
import { calculateBalance } from '@/util/validate'
|
import { calculateBalance } from '@/util/validate'
|
||||||
import { RIGHTS } from '@/auth/RIGHTS'
|
import { RIGHTS } from '@/auth/RIGHTS'
|
||||||
import { calculateDecay } from '@/util/decay'
|
import { calculateDecay } from '@/util/decay'
|
||||||
import { getUserCreation, validateContribution } from './util/creations'
|
|
||||||
import { executeTransaction } from './TransactionResolver'
|
|
||||||
import QueryLinkResult from '@union/QueryLinkResult'
|
import QueryLinkResult from '@union/QueryLinkResult'
|
||||||
import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK'
|
import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK'
|
||||||
import LogError from '@/server/LogError'
|
import LogError from '@/server/LogError'
|
||||||
|
|
||||||
import { getLastTransaction } from './util/getLastTransaction'
|
|
||||||
import transactionLinkList from './util/transactionLinkList'
|
|
||||||
import {
|
import {
|
||||||
EVENT_CONTRIBUTION_LINK_REDEEM,
|
EVENT_CONTRIBUTION_LINK_REDEEM,
|
||||||
EVENT_TRANSACTION_LINK_CREATE,
|
EVENT_TRANSACTION_LINK_CREATE,
|
||||||
|
|||||||
@ -5,7 +5,12 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||||
|
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
|
import { Transaction } from '@entity/Transaction'
|
||||||
|
import { User } from '@entity/User'
|
||||||
|
import { GraphQLError } from 'graphql'
|
||||||
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
import { findUserByEmail } from './UserResolver'
|
||||||
import { EventType } from '@/event/Event'
|
import { EventType } from '@/event/Event'
|
||||||
import { userFactory } from '@/seeds/factory/user'
|
import { userFactory } from '@/seeds/factory/user'
|
||||||
import {
|
import {
|
||||||
@ -18,13 +23,8 @@ import { bobBaumeister } from '@/seeds/users/bob-baumeister'
|
|||||||
import { garrickOllivander } from '@/seeds/users/garrick-ollivander'
|
import { garrickOllivander } from '@/seeds/users/garrick-ollivander'
|
||||||
import { peterLustig } from '@/seeds/users/peter-lustig'
|
import { peterLustig } from '@/seeds/users/peter-lustig'
|
||||||
import { stephenHawking } from '@/seeds/users/stephen-hawking'
|
import { stephenHawking } from '@/seeds/users/stephen-hawking'
|
||||||
import { Event as DbEvent } from '@entity/Event'
|
|
||||||
import { Transaction } from '@entity/Transaction'
|
|
||||||
import { User } from '@entity/User'
|
|
||||||
import { cleanDB, testEnvironment } from '@test/helpers'
|
import { cleanDB, testEnvironment } from '@test/helpers'
|
||||||
import { logger } from '@test/testSetup'
|
import { logger } from '@test/testSetup'
|
||||||
import { GraphQLError } from 'graphql'
|
|
||||||
import { findUserByEmail } from './UserResolver'
|
|
||||||
|
|
||||||
let mutate: any, query: any, con: any
|
let mutate: any, query: any, con: any
|
||||||
let testEnv: any
|
let testEnv: any
|
||||||
|
|||||||
@ -2,13 +2,17 @@
|
|||||||
/* eslint-disable new-cap */
|
/* eslint-disable new-cap */
|
||||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||||
|
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { Resolver, Query, Args, Authorized, Ctx, Mutation } from 'type-graphql'
|
import { Resolver, Query, Args, Authorized, Ctx, Mutation } from 'type-graphql'
|
||||||
import { getCustomRepository, getConnection, In } from '@dbTools/typeorm'
|
import { getCustomRepository, getConnection, In } from '@dbTools/typeorm'
|
||||||
|
|
||||||
import { User as dbUser } from '@entity/User'
|
import { User as dbUser } from '@entity/User'
|
||||||
import { Transaction as dbTransaction } from '@entity/Transaction'
|
import { Transaction as dbTransaction } from '@entity/Transaction'
|
||||||
import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink'
|
import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink'
|
||||||
|
import { BalanceResolver } from './BalanceResolver'
|
||||||
|
import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const'
|
||||||
|
import { findUserByEmail } from './UserResolver'
|
||||||
|
import { getLastTransaction } from './util/getLastTransaction'
|
||||||
import { TransactionRepository } from '@repository/Transaction'
|
import { TransactionRepository } from '@repository/Transaction'
|
||||||
import { TransactionLinkRepository } from '@repository/TransactionLink'
|
import { TransactionLinkRepository } from '@repository/TransactionLink'
|
||||||
|
|
||||||
@ -32,15 +36,9 @@ import {
|
|||||||
} from '@/emails/sendEmailVariants'
|
} from '@/emails/sendEmailVariants'
|
||||||
import { EVENT_TRANSACTION_RECEIVE, EVENT_TRANSACTION_SEND } from '@/event/Event'
|
import { EVENT_TRANSACTION_RECEIVE, EVENT_TRANSACTION_SEND } from '@/event/Event'
|
||||||
|
|
||||||
import { BalanceResolver } from './BalanceResolver'
|
|
||||||
import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const'
|
|
||||||
import { findUserByEmail } from './UserResolver'
|
|
||||||
|
|
||||||
import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK'
|
import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK'
|
||||||
import LogError from '@/server/LogError'
|
import LogError from '@/server/LogError'
|
||||||
|
|
||||||
import { getLastTransaction } from './util/getLastTransaction'
|
|
||||||
|
|
||||||
export const executeTransaction = async (
|
export const executeTransaction = async (
|
||||||
amount: Decimal,
|
amount: Decimal,
|
||||||
memo: string,
|
memo: string,
|
||||||
|
|||||||
@ -6,6 +6,15 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||||
|
|
||||||
|
import { GraphQLError } from 'graphql'
|
||||||
|
import { User } from '@entity/User'
|
||||||
|
import { TransactionLink } from '@entity/TransactionLink'
|
||||||
|
import { validate as validateUUID, version as versionUUID } from 'uuid'
|
||||||
|
import { UserContact } from '@entity/UserContact'
|
||||||
|
import { Event as DbEvent } from '@entity/Event'
|
||||||
|
import { OptInType } from '@enum/OptInType'
|
||||||
|
import { UserContactType } from '@enum/UserContactType'
|
||||||
|
import { PasswordEncryptionType } from '@enum/PasswordEncryptionType'
|
||||||
import { objectValuesToArray } from '@/util/utilities'
|
import { objectValuesToArray } from '@/util/utilities'
|
||||||
import { testEnvironment, headerPushMock, resetToken, cleanDB } from '@test/helpers'
|
import { testEnvironment, headerPushMock, resetToken, cleanDB } from '@test/helpers'
|
||||||
import { logger, i18n as localization } from '@test/testSetup'
|
import { logger, i18n as localization } from '@test/testSetup'
|
||||||
@ -27,8 +36,6 @@ import {
|
|||||||
sendActivationEmail,
|
sendActivationEmail,
|
||||||
} from '@/seeds/graphql/mutations'
|
} from '@/seeds/graphql/mutations'
|
||||||
import { verifyLogin, queryOptIn, searchAdminUsers, searchUsers } from '@/seeds/graphql/queries'
|
import { verifyLogin, queryOptIn, searchAdminUsers, searchUsers } from '@/seeds/graphql/queries'
|
||||||
import { GraphQLError } from 'graphql'
|
|
||||||
import { User } from '@entity/User'
|
|
||||||
import CONFIG from '@/config'
|
import CONFIG from '@/config'
|
||||||
import {
|
import {
|
||||||
sendAccountActivationEmail,
|
sendAccountActivationEmail,
|
||||||
@ -38,19 +45,12 @@ import {
|
|||||||
import { contributionLinkFactory } from '@/seeds/factory/contributionLink'
|
import { contributionLinkFactory } from '@/seeds/factory/contributionLink'
|
||||||
import { transactionLinkFactory } from '@/seeds/factory/transactionLink'
|
import { transactionLinkFactory } from '@/seeds/factory/transactionLink'
|
||||||
import { ContributionLink } from '@model/ContributionLink'
|
import { ContributionLink } from '@model/ContributionLink'
|
||||||
import { TransactionLink } from '@entity/TransactionLink'
|
|
||||||
import { EventType } from '@/event/Event'
|
import { EventType } from '@/event/Event'
|
||||||
import { Event as DbEvent } from '@entity/Event'
|
|
||||||
import { validate as validateUUID, version as versionUUID } from 'uuid'
|
|
||||||
import { peterLustig } from '@/seeds/users/peter-lustig'
|
import { peterLustig } from '@/seeds/users/peter-lustig'
|
||||||
import { UserContact } from '@entity/UserContact'
|
|
||||||
import { OptInType } from '../enum/OptInType'
|
|
||||||
import { UserContactType } from '../enum/UserContactType'
|
|
||||||
import { bobBaumeister } from '@/seeds/users/bob-baumeister'
|
import { bobBaumeister } from '@/seeds/users/bob-baumeister'
|
||||||
import { stephenHawking } from '@/seeds/users/stephen-hawking'
|
import { stephenHawking } from '@/seeds/users/stephen-hawking'
|
||||||
import { garrickOllivander } from '@/seeds/users/garrick-ollivander'
|
import { garrickOllivander } from '@/seeds/users/garrick-ollivander'
|
||||||
import { encryptPassword } from '@/password/PasswordEncryptor'
|
import { encryptPassword } from '@/password/PasswordEncryptor'
|
||||||
import { PasswordEncryptionType } from '../enum/PasswordEncryptionType'
|
|
||||||
import { SecretKeyCryptographyCreateKey } from '@/password/EncryptorUtils'
|
import { SecretKeyCryptographyCreateKey } from '@/password/EncryptorUtils'
|
||||||
|
|
||||||
// import { klicktippSignIn } from '@/apis/KlicktippController'
|
// import { klicktippSignIn } from '@/apis/KlicktippController'
|
||||||
@ -182,14 +182,14 @@ describe('UserResolver', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('stores the REGISTER event in the database', async () => {
|
it('stores the USER_REGISTER event in the database', async () => {
|
||||||
const userConatct = await UserContact.findOneOrFail(
|
const userConatct = await UserContact.findOneOrFail(
|
||||||
{ email: 'peter@lustig.de' },
|
{ email: 'peter@lustig.de' },
|
||||||
{ relations: ['user'] },
|
{ relations: ['user'] },
|
||||||
)
|
)
|
||||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
type: EventType.REGISTER,
|
type: EventType.USER_REGISTER,
|
||||||
affectedUserId: userConatct.user.id,
|
affectedUserId: userConatct.user.id,
|
||||||
actingUserId: userConatct.user.id,
|
actingUserId: userConatct.user.id,
|
||||||
}),
|
}),
|
||||||
@ -216,10 +216,10 @@ describe('UserResolver', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('stores the SEND_CONFIRMATION_EMAIL event in the database', async () => {
|
it('stores the EMAIL_CONFIRMATION event in the database', async () => {
|
||||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
type: EventType.SEND_CONFIRMATION_EMAIL,
|
type: EventType.EMAIL_CONFIRMATION,
|
||||||
affectedUserId: user[0].id,
|
affectedUserId: user[0].id,
|
||||||
actingUserId: user[0].id,
|
actingUserId: user[0].id,
|
||||||
}),
|
}),
|
||||||
@ -258,14 +258,14 @@ describe('UserResolver', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('stores the SEND_ACCOUNT_MULTIREGISTRATION_EMAIL event in the database', async () => {
|
it('stores the EMAIL_ACCOUNT_MULTIREGISTRATION event in the database', async () => {
|
||||||
const userConatct = await UserContact.findOneOrFail(
|
const userConatct = await UserContact.findOneOrFail(
|
||||||
{ email: 'peter@lustig.de' },
|
{ email: 'peter@lustig.de' },
|
||||||
{ relations: ['user'] },
|
{ relations: ['user'] },
|
||||||
)
|
)
|
||||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
type: EventType.SEND_ACCOUNT_MULTIREGISTRATION_EMAIL,
|
type: EventType.EMAIL_ACCOUNT_MULTIREGISTRATION,
|
||||||
affectedUserId: userConatct.user.id,
|
affectedUserId: userConatct.user.id,
|
||||||
actingUserId: 0,
|
actingUserId: 0,
|
||||||
}),
|
}),
|
||||||
@ -363,20 +363,20 @@ describe('UserResolver', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('stores the ACTIVATE_ACCOUNT event in the database', async () => {
|
it('stores the USER_ACTIVATE_ACCOUNT event in the database', async () => {
|
||||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
type: EventType.ACTIVATE_ACCOUNT,
|
type: EventType.USER_ACTIVATE_ACCOUNT,
|
||||||
affectedUserId: user[0].id,
|
affectedUserId: user[0].id,
|
||||||
actingUserId: user[0].id,
|
actingUserId: user[0].id,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('stores the REDEEM_REGISTER event in the database', async () => {
|
it('stores the USER_REGISTER_REDEEM event in the database', async () => {
|
||||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
type: EventType.REDEEM_REGISTER,
|
type: EventType.USER_REGISTER_REDEEM,
|
||||||
affectedUserId: result.data.createUser.id,
|
affectedUserId: result.data.createUser.id,
|
||||||
actingUserId: result.data.createUser.id,
|
actingUserId: result.data.createUser.id,
|
||||||
involvedContributionLinkId: link.id,
|
involvedContributionLinkId: link.id,
|
||||||
@ -458,10 +458,10 @@ describe('UserResolver', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('stores the REDEEM_REGISTER event in the database', async () => {
|
it('stores the USER_REGISTER_REDEEM event in the database', async () => {
|
||||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
type: EventType.REDEEM_REGISTER,
|
type: EventType.USER_REGISTER_REDEEM,
|
||||||
affectedUserId: newUser.data.createUser.id,
|
affectedUserId: newUser.data.createUser.id,
|
||||||
actingUserId: newUser.data.createUser.id,
|
actingUserId: newUser.data.createUser.id,
|
||||||
involvedTransactionLinkId: transactionLink.id,
|
involvedTransactionLinkId: transactionLink.id,
|
||||||
@ -687,14 +687,14 @@ describe('UserResolver', () => {
|
|||||||
expect(headerPushMock).toBeCalledWith({ key: 'token', value: expect.any(String) })
|
expect(headerPushMock).toBeCalledWith({ key: 'token', value: expect.any(String) })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('stores the LOGIN event in the database', async () => {
|
it('stores the USER_LOGIN event in the database', async () => {
|
||||||
const userConatct = await UserContact.findOneOrFail(
|
const userConatct = await UserContact.findOneOrFail(
|
||||||
{ email: 'bibi@bloxberg.de' },
|
{ email: 'bibi@bloxberg.de' },
|
||||||
{ relations: ['user'] },
|
{ relations: ['user'] },
|
||||||
)
|
)
|
||||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
type: EventType.LOGIN,
|
type: EventType.USER_LOGIN,
|
||||||
affectedUserId: userConatct.user.id,
|
affectedUserId: userConatct.user.id,
|
||||||
actingUserId: userConatct.user.id,
|
actingUserId: userConatct.user.id,
|
||||||
}),
|
}),
|
||||||
@ -868,6 +868,20 @@ describe('UserResolver', () => {
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('stores the USER_LOGOUT event in the database', async () => {
|
||||||
|
const userConatct = await UserContact.findOneOrFail(
|
||||||
|
{ email: 'bibi@bloxberg.de' },
|
||||||
|
{ relations: ['user'] },
|
||||||
|
)
|
||||||
|
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
type: EventType.USER_LOGOUT,
|
||||||
|
affectedUserId: userConatct.user.id,
|
||||||
|
actingUserId: userConatct.user.id,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -941,10 +955,10 @@ describe('UserResolver', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('stores the LOGIN event in the database', async () => {
|
it('stores the USER_LOGIN event in the database', async () => {
|
||||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
type: EventType.LOGIN,
|
type: EventType.USER_LOGIN,
|
||||||
affectedUserId: user[0].id,
|
affectedUserId: user[0].id,
|
||||||
actingUserId: user[0].id,
|
actingUserId: user[0].id,
|
||||||
}),
|
}),
|
||||||
@ -1023,6 +1037,20 @@ describe('UserResolver', () => {
|
|||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('stores the EMAIL_FORGOT_PASSWORD event in the database', async () => {
|
||||||
|
const userConatct = await UserContact.findOneOrFail(
|
||||||
|
{ email: 'bibi@bloxberg.de' },
|
||||||
|
{ relations: ['user'] },
|
||||||
|
)
|
||||||
|
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
type: EventType.EMAIL_FORGOT_PASSWORD,
|
||||||
|
affectedUserId: userConatct.user.id,
|
||||||
|
actingUserId: 0,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('request reset password again', () => {
|
describe('request reset password again', () => {
|
||||||
@ -1147,6 +1175,20 @@ describe('UserResolver', () => {
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('stores the USER_INFO_UPDATE event in the database', async () => {
|
||||||
|
const userConatct = await UserContact.findOneOrFail(
|
||||||
|
{ email: 'bibi@bloxberg.de' },
|
||||||
|
{ relations: ['user'] },
|
||||||
|
)
|
||||||
|
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
type: EventType.USER_INFO_UPDATE,
|
||||||
|
affectedUserId: userConatct.user.id,
|
||||||
|
actingUserId: userConatct.user.id,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('language is not valid', () => {
|
describe('language is not valid', () => {
|
||||||
@ -1517,6 +1559,24 @@ describe('UserResolver', () => {
|
|||||||
)
|
)
|
||||||
expect(new Date(result.data.setUserRole)).toEqual(expect.any(Date))
|
expect(new Date(result.data.setUserRole)).toEqual(expect.any(Date))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('stores the ADMIN_USER_ROLE_SET event in the database', async () => {
|
||||||
|
const userConatct = await UserContact.findOneOrFail(
|
||||||
|
{ email: 'bibi@bloxberg.de' },
|
||||||
|
{ relations: ['user'] },
|
||||||
|
)
|
||||||
|
const adminConatct = await UserContact.findOneOrFail(
|
||||||
|
{ email: 'peter@lustig.de' },
|
||||||
|
{ relations: ['user'] },
|
||||||
|
)
|
||||||
|
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
type: EventType.ADMIN_USER_ROLE_SET,
|
||||||
|
affectedUserId: userConatct.user.id,
|
||||||
|
actingUserId: adminConatct.user.id,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('to usual user', () => {
|
describe('to usual user', () => {
|
||||||
@ -1702,6 +1762,24 @@ describe('UserResolver', () => {
|
|||||||
expect(new Date(result.data.deleteUser)).toEqual(expect.any(Date))
|
expect(new Date(result.data.deleteUser)).toEqual(expect.any(Date))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('stores the ADMIN_USER_DELETE event in the database', async () => {
|
||||||
|
const userConatct = await UserContact.findOneOrFail(
|
||||||
|
{ email: 'bibi@bloxberg.de' },
|
||||||
|
{ relations: ['user'], withDeleted: true },
|
||||||
|
)
|
||||||
|
const adminConatct = await UserContact.findOneOrFail(
|
||||||
|
{ email: 'peter@lustig.de' },
|
||||||
|
{ relations: ['user'] },
|
||||||
|
)
|
||||||
|
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
type: EventType.ADMIN_USER_DELETE,
|
||||||
|
affectedUserId: userConatct.user.id,
|
||||||
|
actingUserId: adminConatct.user.id,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
describe('delete deleted user', () => {
|
describe('delete deleted user', () => {
|
||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
jest.clearAllMocks()
|
jest.clearAllMocks()
|
||||||
@ -1857,14 +1935,14 @@ describe('UserResolver', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('stores the ADMIN_SEND_CONFIRMATION_EMAIL event in the database', async () => {
|
it('stores the EMAIL_ADMIN_CONFIRMATION event in the database', async () => {
|
||||||
const userConatct = await UserContact.findOneOrFail(
|
const userConatct = await UserContact.findOneOrFail(
|
||||||
{ email: 'bibi@bloxberg.de' },
|
{ email: 'bibi@bloxberg.de' },
|
||||||
{ relations: ['user'] },
|
{ relations: ['user'] },
|
||||||
)
|
)
|
||||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
type: EventType.ADMIN_SEND_CONFIRMATION_EMAIL,
|
type: EventType.EMAIL_ADMIN_CONFIRMATION,
|
||||||
affectedUserId: userConatct.user.id,
|
affectedUserId: userConatct.user.id,
|
||||||
actingUserId: admin.id,
|
actingUserId: admin.id,
|
||||||
}),
|
}),
|
||||||
@ -1977,6 +2055,24 @@ describe('UserResolver', () => {
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('stores the ADMIN_USER_UNDELETE event in the database', async () => {
|
||||||
|
const userConatct = await UserContact.findOneOrFail(
|
||||||
|
{ email: 'bibi@bloxberg.de' },
|
||||||
|
{ relations: ['user'] },
|
||||||
|
)
|
||||||
|
const adminConatct = await UserContact.findOneOrFail(
|
||||||
|
{ email: 'peter@lustig.de' },
|
||||||
|
{ relations: ['user'] },
|
||||||
|
)
|
||||||
|
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
type: EventType.ADMIN_USER_UNDELETE,
|
||||||
|
affectedUserId: userConatct.user.id,
|
||||||
|
actingUserId: adminConatct.user.id,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -21,6 +21,9 @@ import { User as DbUser } from '@entity/User'
|
|||||||
import { UserContact as DbUserContact } from '@entity/UserContact'
|
import { UserContact as DbUserContact } from '@entity/UserContact'
|
||||||
import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink'
|
import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink'
|
||||||
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
|
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
|
||||||
|
import { getUserCreations } from './util/creations'
|
||||||
|
import { FULL_CREATION_AVAILABLE } from './const/const'
|
||||||
|
import { PasswordEncryptionType } from '@enum/PasswordEncryptionType'
|
||||||
import { UserRepository } from '@repository/User'
|
import { UserRepository } from '@repository/User'
|
||||||
|
|
||||||
import { User } from '@model/User'
|
import { User } from '@model/User'
|
||||||
@ -55,23 +58,26 @@ import { hasElopageBuys } from '@/util/hasElopageBuys'
|
|||||||
import {
|
import {
|
||||||
Event,
|
Event,
|
||||||
EventType,
|
EventType,
|
||||||
EVENT_LOGIN,
|
EVENT_USER_LOGIN,
|
||||||
EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL,
|
EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION,
|
||||||
EVENT_SEND_CONFIRMATION_EMAIL,
|
EVENT_EMAIL_CONFIRMATION,
|
||||||
EVENT_REGISTER,
|
EVENT_USER_REGISTER,
|
||||||
EVENT_ACTIVATE_ACCOUNT,
|
EVENT_USER_ACTIVATE_ACCOUNT,
|
||||||
EVENT_ADMIN_SEND_CONFIRMATION_EMAIL,
|
EVENT_EMAIL_ADMIN_CONFIRMATION,
|
||||||
|
EVENT_USER_LOGOUT,
|
||||||
|
EVENT_EMAIL_FORGOT_PASSWORD,
|
||||||
|
EVENT_USER_INFO_UPDATE,
|
||||||
|
EVENT_ADMIN_USER_ROLE_SET,
|
||||||
|
EVENT_ADMIN_USER_DELETE,
|
||||||
|
EVENT_ADMIN_USER_UNDELETE,
|
||||||
} from '@/event/Event'
|
} from '@/event/Event'
|
||||||
import { getUserCreations } from './util/creations'
|
|
||||||
import { isValidPassword } from '@/password/EncryptorUtils'
|
import { isValidPassword } from '@/password/EncryptorUtils'
|
||||||
import { FULL_CREATION_AVAILABLE } from './const/const'
|
|
||||||
import { encryptPassword, verifyPassword } from '@/password/PasswordEncryptor'
|
import { encryptPassword, verifyPassword } from '@/password/PasswordEncryptor'
|
||||||
import { PasswordEncryptionType } from '../enum/PasswordEncryptionType'
|
|
||||||
import LogError from '@/server/LogError'
|
import LogError from '@/server/LogError'
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
// eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-commonjs
|
||||||
const sodium = require('sodium-native')
|
const sodium = require('sodium-native')
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
// eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-commonjs
|
||||||
const random = require('random-bigint')
|
const random = require('random-bigint')
|
||||||
|
|
||||||
const LANGUAGES = ['de', 'en', 'es', 'fr', 'nl']
|
const LANGUAGES = ['de', 'en', 'es', 'fr', 'nl']
|
||||||
@ -182,22 +188,16 @@ export class UserResolver {
|
|||||||
value: encode(dbUser.gradidoID),
|
value: encode(dbUser.gradidoID),
|
||||||
})
|
})
|
||||||
|
|
||||||
await EVENT_LOGIN(dbUser)
|
await EVENT_USER_LOGIN(dbUser)
|
||||||
logger.info(`successful Login: ${JSON.stringify(user, null, 2)}`)
|
logger.info(`successful Login: ${JSON.stringify(user, null, 2)}`)
|
||||||
return user
|
return user
|
||||||
}
|
}
|
||||||
|
|
||||||
@Authorized([RIGHTS.LOGOUT])
|
@Authorized([RIGHTS.LOGOUT])
|
||||||
@Mutation(() => Boolean)
|
@Mutation(() => Boolean)
|
||||||
logout(): boolean {
|
async logout(@Ctx() context: Context): Promise<boolean> {
|
||||||
// TODO: Event still missing here!!
|
await EVENT_USER_LOGOUT(getUser(context))
|
||||||
// TODO: We dont need this anymore, but might need this in the future in oder to invalidate a valid JWT-Token.
|
// remove user from logger context
|
||||||
// Furthermore this hook can be useful for tracking user behaviour (did he logout or not? Warn him if he didn't on next login)
|
|
||||||
// The functionality is fully client side - the client just needs to delete his token with the current implementation.
|
|
||||||
// we could try to force this by sending `token: null` or `token: ''` with this call. But since it bares no real security
|
|
||||||
// we should just return true for now.
|
|
||||||
logger.info('Logout...')
|
|
||||||
// remove user.pubKey from logger-context to ensure a correct filter on log-messages belonging to the same user
|
|
||||||
logger.addContext('user', 'unknown')
|
logger.addContext('user', 'unknown')
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -251,8 +251,7 @@ export class UserResolver {
|
|||||||
email,
|
email,
|
||||||
language: foundUser.language, // use language of the emails owner for sending
|
language: foundUser.language, // use language of the emails owner for sending
|
||||||
})
|
})
|
||||||
|
await EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION(foundUser)
|
||||||
await EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL(foundUser)
|
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
`sendAccountMultiRegistrationEmail by ${firstName} ${lastName} to ${foundUser.firstName} ${foundUser.lastName} <${email}>`,
|
`sendAccountMultiRegistrationEmail by ${firstName} ${lastName} to ${foundUser.firstName} ${foundUser.lastName} <${email}>`,
|
||||||
@ -271,7 +270,7 @@ export class UserResolver {
|
|||||||
const gradidoID = await newGradidoID()
|
const gradidoID = await newGradidoID()
|
||||||
|
|
||||||
const eventRegisterRedeem = Event(
|
const eventRegisterRedeem = Event(
|
||||||
EventType.REDEEM_REGISTER,
|
EventType.USER_REGISTER_REDEEM,
|
||||||
{ id: 0 } as DbUser,
|
{ id: 0 } as DbUser,
|
||||||
{ id: 0 } as DbUser,
|
{ id: 0 } as DbUser,
|
||||||
)
|
)
|
||||||
@ -337,7 +336,7 @@ export class UserResolver {
|
|||||||
})
|
})
|
||||||
logger.info(`sendAccountActivationEmail of ${firstName}.${lastName} to ${email}`)
|
logger.info(`sendAccountActivationEmail of ${firstName}.${lastName} to ${email}`)
|
||||||
|
|
||||||
await EVENT_SEND_CONFIRMATION_EMAIL(dbUser)
|
await EVENT_EMAIL_CONFIRMATION(dbUser)
|
||||||
|
|
||||||
if (!emailSent) {
|
if (!emailSent) {
|
||||||
logger.debug(`Account confirmation link: ${activationLink}`)
|
logger.debug(`Account confirmation link: ${activationLink}`)
|
||||||
@ -358,7 +357,7 @@ export class UserResolver {
|
|||||||
eventRegisterRedeem.actingUser = dbUser
|
eventRegisterRedeem.actingUser = dbUser
|
||||||
await eventRegisterRedeem.save()
|
await eventRegisterRedeem.save()
|
||||||
} else {
|
} else {
|
||||||
await EVENT_REGISTER(dbUser)
|
await EVENT_USER_REGISTER(dbUser)
|
||||||
}
|
}
|
||||||
|
|
||||||
return new User(dbUser)
|
return new User(dbUser)
|
||||||
@ -411,6 +410,7 @@ export class UserResolver {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
logger.info(`forgotPassword(${email}) successful...`)
|
logger.info(`forgotPassword(${email}) successful...`)
|
||||||
|
await EVENT_EMAIL_FORGOT_PASSWORD(user)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -473,8 +473,6 @@ export class UserResolver {
|
|||||||
|
|
||||||
await queryRunner.commitTransaction()
|
await queryRunner.commitTransaction()
|
||||||
logger.info('User and UserContact data written successfully...')
|
logger.info('User and UserContact data written successfully...')
|
||||||
|
|
||||||
await EVENT_ACTIVATE_ACCOUNT(user)
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await queryRunner.rollbackTransaction()
|
await queryRunner.rollbackTransaction()
|
||||||
throw new LogError('Error on writing User and User Contact data', e)
|
throw new LogError('Error on writing User and User Contact data', e)
|
||||||
@ -492,13 +490,9 @@ export class UserResolver {
|
|||||||
)
|
)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error('Error subscribing to klicktipp', e)
|
logger.error('Error subscribing to klicktipp', e)
|
||||||
// TODO is this a problem?
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
/* uncomment this, when you need the activation link on the console
|
|
||||||
console.log('Could not subscribe to klicktipp')
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
await EVENT_USER_ACTIVATE_ACCOUNT(user)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -535,21 +529,21 @@ export class UserResolver {
|
|||||||
@Ctx() context: Context,
|
@Ctx() context: Context,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
logger.info(`updateUserInfos(${firstName}, ${lastName}, ${language}, ***, ***)...`)
|
logger.info(`updateUserInfos(${firstName}, ${lastName}, ${language}, ***, ***)...`)
|
||||||
const userEntity = getUser(context)
|
const user = getUser(context)
|
||||||
|
|
||||||
if (firstName) {
|
if (firstName) {
|
||||||
userEntity.firstName = firstName
|
user.firstName = firstName
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastName) {
|
if (lastName) {
|
||||||
userEntity.lastName = lastName
|
user.lastName = lastName
|
||||||
}
|
}
|
||||||
|
|
||||||
if (language) {
|
if (language) {
|
||||||
if (!isLanguage(language)) {
|
if (!isLanguage(language)) {
|
||||||
throw new LogError('Given language is not a valid language', language)
|
throw new LogError('Given language is not a valid language', language)
|
||||||
}
|
}
|
||||||
userEntity.language = language
|
user.language = language
|
||||||
i18n.setLocale(language)
|
i18n.setLocale(language)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -561,22 +555,22 @@ export class UserResolver {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!verifyPassword(userEntity, password)) {
|
if (!verifyPassword(user, password)) {
|
||||||
throw new LogError(`Old password is invalid`)
|
throw new LogError(`Old password is invalid`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save new password hash and newly encrypted private key
|
// Save new password hash and newly encrypted private key
|
||||||
userEntity.passwordEncryptionType = PasswordEncryptionType.GRADIDO_ID
|
user.passwordEncryptionType = PasswordEncryptionType.GRADIDO_ID
|
||||||
userEntity.password = encryptPassword(userEntity, passwordNew)
|
user.password = encryptPassword(user, passwordNew)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save hideAmountGDD value
|
// Save hideAmountGDD value
|
||||||
if (hideAmountGDD !== undefined) {
|
if (hideAmountGDD !== undefined) {
|
||||||
userEntity.hideAmountGDD = hideAmountGDD
|
user.hideAmountGDD = hideAmountGDD
|
||||||
}
|
}
|
||||||
// Save hideAmountGDT value
|
// Save hideAmountGDT value
|
||||||
if (hideAmountGDT !== undefined) {
|
if (hideAmountGDT !== undefined) {
|
||||||
userEntity.hideAmountGDT = hideAmountGDT
|
user.hideAmountGDT = hideAmountGDT
|
||||||
}
|
}
|
||||||
|
|
||||||
const queryRunner = getConnection().createQueryRunner()
|
const queryRunner = getConnection().createQueryRunner()
|
||||||
@ -584,7 +578,7 @@ export class UserResolver {
|
|||||||
await queryRunner.startTransaction('REPEATABLE READ')
|
await queryRunner.startTransaction('REPEATABLE READ')
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await queryRunner.manager.save(userEntity).catch((error) => {
|
await queryRunner.manager.save(user).catch((error) => {
|
||||||
throw new LogError('Error saving user', error)
|
throw new LogError('Error saving user', error)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -597,6 +591,8 @@ export class UserResolver {
|
|||||||
await queryRunner.release()
|
await queryRunner.release()
|
||||||
}
|
}
|
||||||
logger.info('updateUserInfos() successfully finished...')
|
logger.info('updateUserInfos() successfully finished...')
|
||||||
|
await EVENT_USER_INFO_UPDATE(user)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -722,8 +718,8 @@ export class UserResolver {
|
|||||||
throw new LogError('Could not find user with given ID', userId)
|
throw new LogError('Could not find user with given ID', userId)
|
||||||
}
|
}
|
||||||
// administrator user changes own role?
|
// administrator user changes own role?
|
||||||
const moderatorUser = getUser(context)
|
const moderator = getUser(context)
|
||||||
if (moderatorUser.id === userId) {
|
if (moderator.id === userId) {
|
||||||
throw new LogError('Administrator can not change his own role')
|
throw new LogError('Administrator can not change his own role')
|
||||||
}
|
}
|
||||||
// change isAdmin
|
// change isAdmin
|
||||||
@ -744,6 +740,7 @@ export class UserResolver {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
await user.save()
|
await user.save()
|
||||||
|
await EVENT_ADMIN_USER_ROLE_SET(user, moderator)
|
||||||
const newUser = await DbUser.findOne({ id: userId })
|
const newUser = await DbUser.findOne({ id: userId })
|
||||||
return newUser ? newUser.isAdmin : null
|
return newUser ? newUser.isAdmin : null
|
||||||
}
|
}
|
||||||
@ -760,19 +757,23 @@ export class UserResolver {
|
|||||||
throw new LogError('Could not find user with given ID', userId)
|
throw new LogError('Could not find user with given ID', userId)
|
||||||
}
|
}
|
||||||
// moderator user disabled own account?
|
// moderator user disabled own account?
|
||||||
const moderatorUser = getUser(context)
|
const moderator = getUser(context)
|
||||||
if (moderatorUser.id === userId) {
|
if (moderator.id === userId) {
|
||||||
throw new LogError('Moderator can not delete his own account')
|
throw new LogError('Moderator can not delete his own account')
|
||||||
}
|
}
|
||||||
// soft-delete user
|
// soft-delete user
|
||||||
await user.softRemove()
|
await user.softRemove()
|
||||||
|
await EVENT_ADMIN_USER_DELETE(user, moderator)
|
||||||
const newUser = await DbUser.findOne({ id: userId }, { withDeleted: true })
|
const newUser = await DbUser.findOne({ id: userId }, { withDeleted: true })
|
||||||
return newUser ? newUser.deletedAt : null
|
return newUser ? newUser.deletedAt : null
|
||||||
}
|
}
|
||||||
|
|
||||||
@Authorized([RIGHTS.UNDELETE_USER])
|
@Authorized([RIGHTS.UNDELETE_USER])
|
||||||
@Mutation(() => Date, { nullable: true })
|
@Mutation(() => Date, { nullable: true })
|
||||||
async unDeleteUser(@Arg('userId', () => Int) userId: number): Promise<Date | null> {
|
async unDeleteUser(
|
||||||
|
@Arg('userId', () => Int) userId: number,
|
||||||
|
@Ctx() context: Context,
|
||||||
|
): Promise<Date | null> {
|
||||||
const user = await DbUser.findOne({ id: userId }, { withDeleted: true })
|
const user = await DbUser.findOne({ id: userId }, { withDeleted: true })
|
||||||
if (!user) {
|
if (!user) {
|
||||||
throw new LogError('Could not find user with given ID', userId)
|
throw new LogError('Could not find user with given ID', userId)
|
||||||
@ -781,6 +782,7 @@ export class UserResolver {
|
|||||||
throw new LogError('User is not deleted')
|
throw new LogError('User is not deleted')
|
||||||
}
|
}
|
||||||
await user.recover()
|
await user.recover()
|
||||||
|
await EVENT_ADMIN_USER_UNDELETE(user, getUser(context))
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -814,9 +816,8 @@ export class UserResolver {
|
|||||||
// In case EMails are disabled log the activation link for the user
|
// In case EMails are disabled log the activation link for the user
|
||||||
if (!emailSent) {
|
if (!emailSent) {
|
||||||
logger.info(`Account confirmation link: ${activationLink}`)
|
logger.info(`Account confirmation link: ${activationLink}`)
|
||||||
} else {
|
|
||||||
await EVENT_ADMIN_SEND_CONFIRMATION_EMAIL(user, getUser(context))
|
|
||||||
}
|
}
|
||||||
|
await EVENT_EMAIL_ADMIN_CONFIRMATION(user, getUser(context))
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
|
|
||||||
export const MAX_CREATION_AMOUNT = new Decimal(1000)
|
export const MAX_CREATION_AMOUNT = new Decimal(1000)
|
||||||
export const FULL_CREATION_AVAILABLE = [
|
export const FULL_CREATION_AVAILABLE = [
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { userFactory } from '@/seeds/factory/user'
|
import { userFactory } from '@/seeds/factory/user'
|
||||||
import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
|
import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
|
||||||
import { bobBaumeister } from '@/seeds/users/bob-baumeister'
|
import { bobBaumeister } from '@/seeds/users/bob-baumeister'
|
||||||
|
|||||||
@ -4,14 +4,14 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||||
|
|
||||||
|
import { User } from '@entity/User'
|
||||||
|
import { Contribution } from '@entity/Contribution'
|
||||||
|
import { getUserCreation } from './creations'
|
||||||
import { testEnvironment, cleanDB, contributionDateFormatter } from '@test/helpers'
|
import { testEnvironment, cleanDB, contributionDateFormatter } from '@test/helpers'
|
||||||
import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
|
import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
|
||||||
import { peterLustig } from '@/seeds/users/peter-lustig'
|
import { peterLustig } from '@/seeds/users/peter-lustig'
|
||||||
import { User } from '@entity/User'
|
|
||||||
import { Contribution } from '@entity/Contribution'
|
|
||||||
import { userFactory } from '@/seeds/factory/user'
|
import { userFactory } from '@/seeds/factory/user'
|
||||||
import { login, createContribution, adminCreateContribution } from '@/seeds/graphql/mutations'
|
import { login, createContribution, adminCreateContribution } from '@/seeds/graphql/mutations'
|
||||||
import { getUserCreation } from './creations'
|
|
||||||
|
|
||||||
let mutate: any, con: any
|
let mutate: any, con: any
|
||||||
let testEnv: any
|
let testEnv: any
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||||
import LogError from '@/server/LogError'
|
|
||||||
import { backendLogger as logger } from '@/server/logger'
|
|
||||||
import { getConnection } from '@dbTools/typeorm'
|
import { getConnection } from '@dbTools/typeorm'
|
||||||
import { Contribution } from '@entity/Contribution'
|
import { Contribution } from '@entity/Contribution'
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { FULL_CREATION_AVAILABLE, MAX_CREATION_AMOUNT } from '../const/const'
|
import { FULL_CREATION_AVAILABLE, MAX_CREATION_AMOUNT } from '@/graphql/resolver/const/const'
|
||||||
|
import { backendLogger as logger } from '@/server/logger'
|
||||||
import { OpenCreation } from '@model/OpenCreation'
|
import { OpenCreation } from '@model/OpenCreation'
|
||||||
|
import LogError from '@/server/LogError'
|
||||||
|
|
||||||
interface CreationMap {
|
interface CreationMap {
|
||||||
id: number
|
id: number
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { ContributionStatus } from '@enum/ContributionStatus'
|
|
||||||
import { Order } from '@enum/Order'
|
|
||||||
import { Contribution as DbContribution } from '@entity/Contribution'
|
import { Contribution as DbContribution } from '@entity/Contribution'
|
||||||
import { In } from '@dbTools/typeorm'
|
import { In } from '@dbTools/typeorm'
|
||||||
|
import { ContributionStatus } from '@enum/ContributionStatus'
|
||||||
|
import { Order } from '@enum/Order'
|
||||||
|
|
||||||
interface FindContributionsOptions {
|
interface FindContributionsOptions {
|
||||||
order: Order
|
order: Order
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { GraphQLScalarType, Kind } from 'graphql'
|
import { GraphQLScalarType, Kind } from 'graphql'
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
|
|
||||||
export default new GraphQLScalarType({
|
const DecimalType = new GraphQLScalarType({
|
||||||
name: 'Decimal',
|
name: 'Decimal',
|
||||||
description: 'The `Decimal` scalar type to represent currency values',
|
description: 'The `Decimal` scalar type to represent currency values',
|
||||||
|
|
||||||
@ -21,3 +21,5 @@ export default new GraphQLScalarType({
|
|||||||
return new Decimal(ast.value)
|
return new Decimal(ast.value)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export default DecimalType
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
|
import path from 'path'
|
||||||
import { GraphQLSchema } from 'graphql'
|
import { GraphQLSchema } from 'graphql'
|
||||||
import { buildSchema } from 'type-graphql'
|
import { buildSchema } from 'type-graphql'
|
||||||
import path from 'path'
|
|
||||||
|
|
||||||
|
import { Decimal } from 'decimal.js-light'
|
||||||
import isAuthorized from './directive/isAuthorized'
|
import isAuthorized from './directive/isAuthorized'
|
||||||
import DecimalScalar from './scalar/Decimal'
|
import DecimalScalar from './scalar/Decimal'
|
||||||
import Decimal from 'decimal.js-light'
|
|
||||||
|
|
||||||
const schema = async (): Promise<GraphQLSchema> => {
|
const schema = async (): Promise<GraphQLSchema> => {
|
||||||
return buildSchema({
|
return buildSchema({
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import { createUnionType } from 'type-graphql'
|
import { createUnionType } from 'type-graphql'
|
||||||
import { TransactionLink } from '@model/TransactionLink'
|
import { TransactionLink } from '@model/TransactionLink'
|
||||||
import { ContributionLink } from '@model/ContributionLink'
|
import { ContributionLink } from '@model/ContributionLink'
|
||||||
|
|
||||||
export default createUnionType({
|
export default createUnionType({
|
||||||
name: 'QueryLinkResult', // the name of the GraphQL union
|
name: 'QueryLinkResult', // the name of the GraphQL union
|
||||||
types: () => [TransactionLink, ContributionLink] as const, // function that returns tuple of object types classes
|
types: () => [TransactionLink, ContributionLink] as const, // function that returns tuple of object types classes
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||||
|
import { User } from '@entity/User'
|
||||||
import CONFIG from '@/config'
|
import CONFIG from '@/config'
|
||||||
import LogError from '@/server/LogError'
|
import LogError from '@/server/LogError'
|
||||||
import { backendLogger as logger } from '@/server/logger'
|
import { backendLogger as logger } from '@/server/logger'
|
||||||
import { User } from '@entity/User'
|
|
||||||
import { PasswordEncryptionType } from '@enum/PasswordEncryptionType'
|
import { PasswordEncryptionType } from '@enum/PasswordEncryptionType'
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
// eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-commonjs
|
||||||
const sodium = require('sodium-native')
|
const sodium = require('sodium-native')
|
||||||
|
|
||||||
// We will reuse this for changePassword
|
// We will reuse this for changePassword
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { CreationInterface } from './CreationInterface'
|
import { CreationInterface } from './CreationInterface'
|
||||||
import { nMonthsBefore } from '../factory/creation'
|
import { nMonthsBefore } from '@/seeds/factory/creation'
|
||||||
|
|
||||||
const bobsSendings = [
|
const bobsSendings = [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,11 +5,11 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||||
|
|
||||||
import { login, createContribution, confirmContribution } from '@/seeds/graphql/mutations'
|
|
||||||
import { CreationInterface } from '@/seeds/creation/CreationInterface'
|
|
||||||
import { ApolloServerTestClient } from 'apollo-server-testing'
|
import { ApolloServerTestClient } from 'apollo-server-testing'
|
||||||
import { Transaction } from '@entity/Transaction'
|
import { Transaction } from '@entity/Transaction'
|
||||||
import { Contribution } from '@entity/Contribution'
|
import { Contribution } from '@entity/Contribution'
|
||||||
|
import { CreationInterface } from '@/seeds/creation/CreationInterface'
|
||||||
|
import { login, createContribution, confirmContribution } from '@/seeds/graphql/mutations'
|
||||||
import { findUserByEmail } from '@/graphql/resolver/UserResolver'
|
import { findUserByEmail } from '@/graphql/resolver/UserResolver'
|
||||||
// import CONFIG from '@/config/index'
|
// import CONFIG from '@/config/index'
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||||
/* eslint-disable @typescript-eslint/unbound-method */
|
/* eslint-disable @typescript-eslint/unbound-method */
|
||||||
import { ApolloServerTestClient } from 'apollo-server-testing'
|
import { ApolloServerTestClient } from 'apollo-server-testing'
|
||||||
|
import { TransactionLink } from '@entity/TransactionLink'
|
||||||
import { login, createTransactionLink } from '@/seeds/graphql/mutations'
|
import { login, createTransactionLink } from '@/seeds/graphql/mutations'
|
||||||
import { TransactionLinkInterface } from '@/seeds/transactionLink/TransactionLinkInterface'
|
import { TransactionLinkInterface } from '@/seeds/transactionLink/TransactionLinkInterface'
|
||||||
import { transactionLinkExpireDate } from '@/graphql/resolver/TransactionLinkResolver'
|
import { transactionLinkExpireDate } from '@/graphql/resolver/TransactionLinkResolver'
|
||||||
import { TransactionLink } from '@entity/TransactionLink'
|
|
||||||
|
|
||||||
export const transactionLinkFactory = async (
|
export const transactionLinkFactory = async (
|
||||||
client: ApolloServerTestClient,
|
client: ApolloServerTestClient,
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||||
/* eslint-disable @typescript-eslint/unbound-method */
|
/* eslint-disable @typescript-eslint/unbound-method */
|
||||||
import { createUser, setPassword } from '@/seeds/graphql/mutations'
|
|
||||||
import { User } from '@entity/User'
|
import { User } from '@entity/User'
|
||||||
import { UserInterface } from '@/seeds/users/UserInterface'
|
|
||||||
import { ApolloServerTestClient } from 'apollo-server-testing'
|
import { ApolloServerTestClient } from 'apollo-server-testing'
|
||||||
|
import { createUser, setPassword } from '@/seeds/graphql/mutations'
|
||||||
|
import { UserInterface } from '@/seeds/users/UserInterface'
|
||||||
|
|
||||||
export const userFactory = async (
|
export const userFactory = async (
|
||||||
client: ApolloServerTestClient,
|
client: ApolloServerTestClient,
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import gql from 'graphql-tag'
|
import { gql } from 'graphql-tag'
|
||||||
|
|
||||||
export const subscribeNewsletter = gql`
|
export const subscribeNewsletter = gql`
|
||||||
mutation ($email: String!, $language: String!) {
|
mutation ($email: String!, $language: String!) {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import gql from 'graphql-tag'
|
import { gql } from 'graphql-tag'
|
||||||
|
|
||||||
export const verifyLogin = gql`
|
export const verifyLogin = gql`
|
||||||
query {
|
query {
|
||||||
|
|||||||
@ -5,11 +5,9 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||||
|
|
||||||
import { backendLogger as logger } from '@/server/logger'
|
|
||||||
import createServer from '../server/createServer'
|
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
|
|
||||||
import { name, internet, datatype } from 'faker'
|
import { name, internet, datatype } from 'faker'
|
||||||
|
import { entities } from '@entity/index'
|
||||||
|
|
||||||
import { users } from './users/index'
|
import { users } from './users/index'
|
||||||
import { creations } from './creation/index'
|
import { creations } from './creation/index'
|
||||||
@ -19,7 +17,8 @@ import { userFactory } from './factory/user'
|
|||||||
import { creationFactory } from './factory/creation'
|
import { creationFactory } from './factory/creation'
|
||||||
import { transactionLinkFactory } from './factory/transactionLink'
|
import { transactionLinkFactory } from './factory/transactionLink'
|
||||||
import { contributionLinkFactory } from './factory/contributionLink'
|
import { contributionLinkFactory } from './factory/contributionLink'
|
||||||
import { entities } from '@entity/index'
|
import createServer from '@/server/createServer'
|
||||||
|
import { backendLogger as logger } from '@/server/logger'
|
||||||
import CONFIG from '@/config'
|
import CONFIG from '@/config'
|
||||||
|
|
||||||
CONFIG.EMAIL = false
|
CONFIG.EMAIL = false
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||||
/* eslint-disable @typescript-eslint/unbound-method */
|
/* eslint-disable @typescript-eslint/unbound-method */
|
||||||
import { logger } from '@test/testSetup'
|
|
||||||
|
|
||||||
import LogError from './LogError'
|
import LogError from './LogError'
|
||||||
|
import { logger } from '@test/testSetup'
|
||||||
|
|
||||||
describe('LogError', () => {
|
describe('LogError', () => {
|
||||||
it('logs an Error when created', () => {
|
it('logs an Error when created', () => {
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import { Role } from '@/auth/Role'
|
|
||||||
import { User as dbUser } from '@entity/User'
|
import { User as dbUser } from '@entity/User'
|
||||||
import { Transaction as dbTransaction } from '@entity/Transaction'
|
import { Transaction as dbTransaction } from '@entity/Transaction'
|
||||||
import Decimal from 'decimal.js-light'
|
import { Decimal } from 'decimal.js-light'
|
||||||
import { ExpressContext } from 'apollo-server-express'
|
import { ExpressContext } from 'apollo-server-express'
|
||||||
import LogError from './LogError'
|
import LogError from './LogError'
|
||||||
|
import { Role } from '@/auth/Role'
|
||||||
|
|
||||||
export interface Context {
|
export interface Context {
|
||||||
token: string | null
|
token: string | null
|
||||||
|
|||||||
@ -1,35 +1,20 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||||
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
||||||
/* eslint-disable @typescript-eslint/unbound-method */
|
/* eslint-disable @typescript-eslint/unbound-method */
|
||||||
import 'reflect-metadata'
|
|
||||||
|
|
||||||
import { ApolloServer } from 'apollo-server-express'
|
import { ApolloServer } from 'apollo-server-express'
|
||||||
import express, { Express } from 'express'
|
import express, { Express, json, urlencoded } from 'express'
|
||||||
|
import { Connection } from '@dbTools/typeorm'
|
||||||
// database
|
import { Logger } from 'log4js'
|
||||||
import connection from '@/typeorm/connection'
|
|
||||||
import { checkDBVersion } from '@/typeorm/DBVersion'
|
|
||||||
|
|
||||||
// server
|
|
||||||
import cors from './cors'
|
import cors from './cors'
|
||||||
import serverContext from './context'
|
import serverContext from './context'
|
||||||
import plugins from './plugins'
|
import plugins from './plugins'
|
||||||
|
|
||||||
// config
|
|
||||||
import CONFIG from '@/config'
|
|
||||||
|
|
||||||
// graphql
|
|
||||||
import schema from '@/graphql/schema'
|
|
||||||
|
|
||||||
// webhooks
|
|
||||||
import { elopageWebhook } from '@/webhook/elopage'
|
|
||||||
import { Connection } from '@dbTools/typeorm'
|
|
||||||
|
|
||||||
import { apolloLogger } from './logger'
|
import { apolloLogger } from './logger'
|
||||||
import { Logger } from 'log4js'
|
|
||||||
|
|
||||||
// i18n
|
|
||||||
import { i18n } from './localization'
|
import { i18n } from './localization'
|
||||||
|
import connection from '@/typeorm/connection'
|
||||||
|
import { checkDBVersion } from '@/typeorm/DBVersion'
|
||||||
|
import CONFIG from '@/config'
|
||||||
|
import schema from '@/graphql/schema'
|
||||||
|
import { elopageWebhook } from '@/webhook/elopage'
|
||||||
|
|
||||||
// TODO implement
|
// TODO implement
|
||||||
// import queryComplexity, { simpleEstimator, fieldConfigEstimator } from "graphql-query-complexity";
|
// import queryComplexity, { simpleEstimator, fieldConfigEstimator } from "graphql-query-complexity";
|
||||||
@ -66,9 +51,9 @@ const createServer = async (
|
|||||||
app.use(cors)
|
app.use(cors)
|
||||||
|
|
||||||
// bodyparser json
|
// bodyparser json
|
||||||
app.use(express.json())
|
app.use(json())
|
||||||
// bodyparser urlencoded for elopage
|
// bodyparser urlencoded for elopage
|
||||||
app.use(express.urlencoded({ extended: true }))
|
app.use(urlencoded({ extended: true }))
|
||||||
|
|
||||||
// i18n
|
// i18n
|
||||||
app.use(localization.init)
|
app.use(localization.init)
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user