Merge branch 'master' into event_refactor_database

This commit is contained in:
Ulf Gebhardt 2023-03-14 16:08:41 +01:00
commit b3c48af3c4
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
128 changed files with 1121 additions and 757 deletions

31
.github/file-filters.yml vendored Normal file
View File

@ -0,0 +1,31 @@
# These file filter patterns are used by the action https://github.com/dorny/paths-filter
# more differentiated filters for admin interface, which might be used later
# admin_locales: &admin_locales
# - 'admin/src/locales/**'
# - 'admin/scripts/sort*'
# admin_stylelinting: &admin_stylelinting
# - 'admin/{components,layouts,pages}/**/*.{scss,vue}'
# - 'admin/.stylelintrc.js'
# admin_linting: &admin_linting
# - 'admin/.eslint*'
# - 'admin/babel.config.js'
# - 'admin/package.json'
# - 'admin/**/*.{js,vue}'
# - *admin_locales
# admin_unit_testing: &admin_unit_testing
# - 'admin/package.json'
# - 'admin/{jest,vue}.config.js'
# - 'admin/{public,run,test}/**/*'
# - 'admin/src/!(locales)/**/*'
# admin_docker_building: &admin_docker_building
# - 'admin/.dockerignore'
# - 'admin/Dockerfile'
# - *admin_unit_testing
admin: &admin
- 'admin/**/*'

View File

@ -0,0 +1,84 @@
name: Gradido Admin Interface Test CI
on: push
jobs:
# only (but most important) job from this workflow required for pull requests
# check results serve as run conditions for all other jobs here
files-changed:
name: Detect File Changes - Admin Interface
runs-on: ubuntu-latest
outputs:
admin: ${{ steps.changes.outputs.admin }}
steps:
- uses: actions/checkout@v3.3.0
- name: Check for admin interface file changes
uses: dorny/paths-filter@v2.11.1
id: changes
with:
token: ${{ github.token }}
filters: .github/file-filters.yml
list-files: shell
build_test:
if: needs.files-changed.outputs.admin == 'true'
name: Docker Build Test - Admin Interface
needs: files-changed
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Admin Interface | Build 'test' image
run: docker build --target test -t "gradido/admin:test" admin/ --build-arg NODE_ENV="test"
unit_test:
if: needs.files-changed.outputs.admin == 'true'
name: Unit Tests - Admin Interface
needs: files-changed
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Admin Interface | Unit tests
run: cd admin && yarn && yarn run test
lint:
if: needs.files-changed.outputs.admin == 'true'
name: Lint - Admin Interface
needs: files-changed
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Admin Interface | Lint
run: cd admin && yarn && yarn run lint
stylelint:
if: needs.files-changed.outputs.admin == 'true'
name: Stylelint - Admin Interface
needs: files-changed
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Admin Interface | Stylelint
run: cd admin && yarn && yarn run stylelint
locales:
if: needs.files-changed.outputs.admin == 'true'
name: Locales - Admin Interface
needs: files-changed
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Admin Interface | Locales
run: cd admin && yarn && yarn run locales

View File

@ -29,31 +29,6 @@ jobs:
name: docker-frontend-test name: docker-frontend-test
path: /tmp/frontend.tar path: /tmp/frontend.tar
##############################################################################
# JOB: DOCKER BUILD TEST ADMIN INTERFACE #####################################
##############################################################################
build_test_admin:
name: Docker Build Test - Admin Interface
runs-on: ubuntu-latest
steps:
##########################################################################
# CHECKOUT CODE ##########################################################
##########################################################################
- name: Checkout code
uses: actions/checkout@v3
##########################################################################
# ADMIN INTERFACE ########################################################
##########################################################################
- name: Admin | Build `test` image
run: |
docker build --target test -t "gradido/admin:test" admin/ --build-arg NODE_ENV="test"
docker save "gradido/admin:test" > /tmp/admin.tar
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: docker-admin-test
path: /tmp/admin.tar
############################################################################## ##############################################################################
# JOB: DOCKER BUILD TEST BACKEND ############################################# # JOB: DOCKER BUILD TEST BACKEND #############################################
############################################################################## ##############################################################################
@ -211,60 +186,6 @@ jobs:
- name: Frontend | Stylelint - name: Frontend | Stylelint
run: cd frontend && yarn && yarn run stylelint run: cd frontend && yarn && yarn run stylelint
##############################################################################
# JOB: LINT ADMIN INTERFACE ##################################################
##############################################################################
lint_admin:
name: Lint - Admin Interface
runs-on: ubuntu-latest
steps:
##########################################################################
# CHECKOUT CODE ##########################################################
##########################################################################
- name: Checkout code
uses: actions/checkout@v3
##########################################################################
# LINT ADMIN INTERFACE ###################################################
##########################################################################
- name: Admin Interface | Lint
run: cd admin && yarn && yarn run lint
##############################################################################
# JOB: STYLELINT ADMIN INTERFACE #############################################
##############################################################################
stylelint_admin:
name: Stylelint - Admin Interface
runs-on: ubuntu-latest
steps:
##########################################################################
# CHECKOUT CODE ##########################################################
##########################################################################
- name: Checkout code
uses: actions/checkout@v3
##########################################################################
# STYLELINT ADMIN INTERFACE ##############################################
##########################################################################
- name: Admin Interface | Stylelint
run: cd admin && yarn && yarn run stylelint
##############################################################################
# JOB: LOCALES ADMIN #########################################################
##############################################################################
locales_admin:
name: Locales - Admin Interface
runs-on: ubuntu-latest
steps:
##########################################################################
# CHECKOUT CODE ##########################################################
##########################################################################
- name: Checkout code
uses: actions/checkout@v3
##########################################################################
# LOCALES FRONTEND #######################################################
##########################################################################
- name: Admin | Locales
run: cd admin && yarn && yarn run locales
############################################################################## ##############################################################################
# JOB: LINT BACKEND ########################################################## # JOB: LINT BACKEND ##########################################################
############################################################################## ##############################################################################
@ -281,7 +202,7 @@ jobs:
# LINT BACKEND ########################################################### # LINT BACKEND ###########################################################
########################################################################## ##########################################################################
- name: backend | Lint - name: backend | Lint
run: cd backend && yarn && yarn run lint run: cd database && yarn && cd ../backend && yarn && yarn run lint
############################################################################## ##############################################################################
# JOB: LOCALES BACKEND ####################################################### # JOB: LOCALES BACKEND #######################################################
@ -335,51 +256,7 @@ jobs:
# UNIT TESTS FRONTEND #################################################### # UNIT TESTS FRONTEND ####################################################
########################################################################## ##########################################################################
- name: Frontend | Unit tests - name: Frontend | Unit tests
run: | run: cd frontend && yarn && yarn run test
cd frontend && yarn && yarn run test
cp -r ./coverage ../
##########################################################################
# COVERAGE CHECK FRONTEND ################################################
##########################################################################
- name: frontend | Coverage check
uses: webcraftmedia/coverage-check-action@master
with:
report_name: Coverage Frontend
type: lcov
result_path: ./frontend/coverage/lcov.info
min_coverage: 95
token: ${{ github.token }}
##############################################################################
# JOB: UNIT TEST ADMIN INTERFACE #############################################
##############################################################################
unit_test_admin:
name: Unit tests - Admin Interface
runs-on: ubuntu-latest
steps:
##########################################################################
# CHECKOUT CODE ##########################################################
##########################################################################
- name: Checkout code
uses: actions/checkout@v3
##########################################################################
# UNIT TESTS ADMIN INTERFACE #############################################
##########################################################################
- name: Admin Interface | Unit tests
run: |
cd admin && yarn && yarn run test
cp -r ./coverage ../
##########################################################################
# COVERAGE CHECK ADMIN INTERFACE #########################################
##########################################################################
- name: Admin Interface | Coverage check
uses: webcraftmedia/coverage-check-action@master
with:
report_name: Coverage Admin Interface
type: lcov
result_path: ./admin/coverage/lcov.info
min_coverage: 97
token: ${{ github.token }}
############################################################################## ##############################################################################
# JOB: UNIT TEST BACKEND #################################################### # JOB: UNIT TEST BACKEND ####################################################
@ -415,20 +292,7 @@ jobs:
- name: backend | docker-compose database - name: backend | docker-compose database
run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps database run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps database
- name: backend Unit tests | test - name: backend Unit tests | test
run: | run: cd database && yarn && yarn build && cd ../backend && yarn && yarn test
cd database && yarn && yarn build && cd ../backend && yarn && yarn test
cp -r ./coverage ../
##########################################################################
# COVERAGE CHECK BACKEND #################################################
##########################################################################
- name: backend | Coverage check
uses: webcraftmedia/coverage-check-action@master
with:
report_name: Coverage Backend
type: lcov
result_path: ./backend/coverage/lcov.info
min_coverage: 80
token: ${{ github.token }}
########################################################################## ##########################################################################
# DATABASE MIGRATION TEST UP + RESET ##################################### # DATABASE MIGRATION TEST UP + RESET #####################################
@ -459,7 +323,7 @@ jobs:
end-to-end-tests: end-to-end-tests:
name: End-to-End Tests name: End-to-End Tests
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [build_test_mariadb, build_test_database_up, build_test_admin, build_test_frontend, build_test_nginx] needs: [build_test_mariadb, build_test_database_up, build_test_frontend, build_test_nginx]
steps: steps:
########################################################################## ##########################################################################
# CHECKOUT CODE ########################################################## # CHECKOUT CODE ##########################################################
@ -490,13 +354,6 @@ jobs:
path: /tmp path: /tmp
- name: Load Docker Image (Frontend) - name: Load Docker Image (Frontend)
run: docker load < /tmp/frontend.tar run: docker load < /tmp/frontend.tar
- name: Download Docker Image (Admin Interface)
uses: actions/download-artifact@v3
with:
name: docker-admin-test
path: /tmp
- name: Load Docker Image (Admin Interface)
run: docker load < /tmp/admin.tar
- name: Download Docker Image (Nginx) - name: Download Docker Image (Nginx)
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
@ -550,7 +407,7 @@ jobs:
run: | run: |
cd e2e-tests/ cd e2e-tests/
yarn yarn
yarn run cypress run --spec cypress/e2e/User.Authentication.feature,cypress/e2e/User.Authentication.ResetPassword.feature,cypress/e2e/User.Registration.feature yarn run cypress run
- name: End-to-end tests | if tests failed, upload screenshots - name: End-to-end tests | if tests failed, upload screenshots
if: ${{ failure() && steps.e2e-tests.conclusion == 'failure' }} if: ${{ failure() && steps.e2e-tests.conclusion == 'failure' }}
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3

View File

@ -83,16 +83,4 @@ jobs:
#- name: Unit tests #- name: Unit tests
# run: cd database && yarn && yarn build && cd ../dht-node && yarn && yarn test # run: cd database && yarn && yarn build && cd ../dht-node && yarn && yarn test
- name: Unit tests - name: Unit tests
run: | run: docker run --env NODE_ENV=test --env DB_HOST=mariadb --network gradido_internal-net --rm gradido/dht-node:test yarn run test
docker run --env NODE_ENV=test --env DB_HOST=mariadb --network gradido_internal-net -v ~/coverage:/app/coverage --rm gradido/dht-node:test yarn run test
cp -r ~/coverage ./coverage
- name: Coverage check
uses: webcraftmedia/coverage-check-action@master
with:
report_name: Coverage DHT Node
type: lcov
#result_path: ./dht-node/coverage/lcov.info
result_path: ./coverage/lcov.info
min_coverage: 79
token: ${{ github.token }}

View File

@ -84,15 +84,4 @@ jobs:
# run: cd database && yarn && yarn build && cd ../dht-node && yarn && yarn test # run: cd database && yarn && yarn build && cd ../dht-node && yarn && yarn test
- name: Unit tests - name: Unit tests
run: | run: |
docker run --env NODE_ENV=test --env DB_HOST=mariadb --network gradido_internal-net -v ~/coverage:/app/coverage --rm gradido/federation:test yarn run test docker run --env NODE_ENV=test --env DB_HOST=mariadb --network gradido_internal-net --rm gradido/federation:test yarn run test
cp -r ~/coverage ./coverage
- name: Coverage check
uses: webcraftmedia/coverage-check-action@master
with:
report_name: Coverage Federation
type: lcov
#result_path: ./federation/coverage/lcov.info
result_path: ./coverage/lcov.info
min_coverage: 72
token: ${{ github.token }}

View File

@ -4,8 +4,76 @@ All notable changes to this project will be documented in this file. Dates are d
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
#### [1.19.1](https://github.com/gradido/gradido/compare/1.19.0...1.19.1)
- fix(frontend): admin question clickable [`#2810`](https://github.com/gradido/gradido/pull/2810)
- refactor(frontend): change b-img to b-icon send [`#2809`](https://github.com/gradido/gradido/pull/2809)
- fix(admin): update openCreation in case of tab open. [`#2806`](https://github.com/gradido/gradido/pull/2806)
- fix(admin): english language for contributions in admin [`#2804`](https://github.com/gradido/gradido/pull/2804)
- refactor(admin): event buttons for myself turned off in open contributions [`#2760`](https://github.com/gradido/gradido/pull/2760)
- fix(admin): contribution page [`#2794`](https://github.com/gradido/gradido/pull/2794)
- fix(frontend): info.svg [`#2798`](https://github.com/gradido/gradido/pull/2798)
- fix(backend): add relation messages to database query [`#2795`](https://github.com/gradido/gradido/pull/2795)
- fix(admin): header and menu [`#2793`](https://github.com/gradido/gradido/pull/2793)
- fix(frontend): send gdd - change first submit button text to 'Check Now' [`#2774`](https://github.com/gradido/gradido/pull/2774)
- refactor(frontend): creations generated by link NL [`#2771`](https://github.com/gradido/gradido/pull/2771)
- refactor(frontend): creations generated by link (FR) + (NL) [`#2770`](https://github.com/gradido/gradido/pull/2770)
- refactor(frontend): update German locales [`#2765`](https://github.com/gradido/gradido/pull/2765)
- refactor(backend): use find contributions helper for list contributions [`#2762`](https://github.com/gradido/gradido/pull/2762)
#### [1.19.0](https://github.com/gradido/gradido/compare/1.18.2...1.19.0)
> 7 March 2023
- chore(release): version 1.19.0 [`#2786`](https://github.com/gradido/gradido/pull/2786)
- fix(frontend): change contribution design [`#2731`](https://github.com/gradido/gradido/pull/2731)
- refactor(frontend): commnity navbar- & unauthenticated b-gradido styles [`#2732`](https://github.com/gradido/gradido/pull/2732)
- fix(database): change downwards migration to delete entries with last_announced_at IS NULL [`#2767`](https://github.com/gradido/gradido/pull/2767)
- feat(admin): deleted contributions visible [`#2759`](https://github.com/gradido/gradido/pull/2759)
- feat(other): e2e test user story user registration [`#2753`](https://github.com/gradido/gradido/pull/2753)
- refactor(frontend): style and design changes to a contribution [`#2648`](https://github.com/gradido/gradido/pull/2648)
- test(backend): add tests that ``sendContributionDeleted`` and ``sendContributionDenied`` are called [`#2740`](https://github.com/gradido/gradido/pull/2740)
- fix(backend): set email tls true in test [`#2763`](https://github.com/gradido/gradido/pull/2763)
- refactor(frontend): add visible event an answer question [`#2750`](https://github.com/gradido/gradido/pull/2750)
- refactor(frontend): style sidebar, add icons [`#2737`](https://github.com/gradido/gradido/pull/2737)
- fix(backend): possible flaky test [`#2761`](https://github.com/gradido/gradido/pull/2761)
- fix(backend): emails adjust namings of menus to new design [`#2756`](https://github.com/gradido/gradido/pull/2756)
- ci(other): rename dht node and federation workflow jobs for better branch protection maintenance [`#2743`](https://github.com/gradido/gradido/pull/2743)
- refactor(backend): combine logic for `listTransactionLinks` & `listTransactionLinksAdmin` [`#2706`](https://github.com/gradido/gradido/pull/2706)
- refactor(backend): remove admin create contributions [`#2724`](https://github.com/gradido/gradido/pull/2724)
- refactor(frontend): remove .vue as imports [`#2725`](https://github.com/gradido/gradido/pull/2725)
- feat(federation): add dht-node to deployment scripts [`#2729`](https://github.com/gradido/gradido/pull/2729)
- fix(frontend): change fetchPolicy, add scripts.update [`#2718`](https://github.com/gradido/gradido/pull/2718)
- refactor(backend): list unconfirmed contribution to admin list all contribution [`#2666`](https://github.com/gradido/gradido/pull/2666)
- refactor(frontend): community routes [`#2721`](https://github.com/gradido/gradido/pull/2721)
- test(backend): authentication tests for TransactionLinkResolver [`#2705`](https://github.com/gradido/gradido/pull/2705)
- refactor(backend): use LogError on errors [`#2679`](https://github.com/gradido/gradido/pull/2679)
- refactor(backend): use LogError on encryptorUtils [`#2678`](https://github.com/gradido/gradido/pull/2678)
- refactor(backend): use LogError on creations [`#2677`](https://github.com/gradido/gradido/pull/2677)
- refactor(other): decrease docker build dependencies in test workflow [`#2719`](https://github.com/gradido/gradido/pull/2719)
- refactor(backend): unit test for the method denyContribution [`#2639`](https://github.com/gradido/gradido/pull/2639)
- refactor(frontend): logo inserted with better quality. [`#2646`](https://github.com/gradido/gradido/pull/2646)
- feat(federation): harmonize and sync modules and data of federation [`#2665`](https://github.com/gradido/gradido/pull/2665)
- feat(federation): add docker and github-workflow files [`#2680`](https://github.com/gradido/gradido/pull/2680)
- feat(other): e2e test user authentication reset password [`#2644`](https://github.com/gradido/gradido/pull/2644)
- refactor(admin): add tabs for all statusus on contributions [`#2623`](https://github.com/gradido/gradido/pull/2623)
- feat(federation): implement a graphql client to request getpublickey [`#2511`](https://github.com/gradido/gradido/pull/2511)
- refactor(frontend): style refactor mobil auth area [`#2643`](https://github.com/gradido/gradido/pull/2643)
- refactor(backend): use LogError on TransactionResolver [`#2676`](https://github.com/gradido/gradido/pull/2676)
- refactor(backend): event protocol rework [`#2691`](https://github.com/gradido/gradido/pull/2691)
- refactor(backend): use LogError on TransactionLinkResolver [`#2673`](https://github.com/gradido/gradido/pull/2673)
- fix(frontend): simple disabled function on submit send [`#2647`](https://github.com/gradido/gradido/pull/2647)
- refactor(frontend): missing message on old transactions [`#2660`](https://github.com/gradido/gradido/pull/2660)
- refactor(admin): remove overview and multi creation menu entry [`#2661`](https://github.com/gradido/gradido/pull/2661)
- feat(other): add locales check to backend and integrate it to test workflow [`#2693`](https://github.com/gradido/gradido/pull/2693)
- refactor(other): add linting rules like in backend modul [`#2695`](https://github.com/gradido/gradido/pull/2695)
- refactor(backend): use LogError on contributionResolver [`#2669`](https://github.com/gradido/gradido/pull/2669)
#### [1.18.2](https://github.com/gradido/gradido/compare/1.18.1...1.18.2) #### [1.18.2](https://github.com/gradido/gradido/compare/1.18.1...1.18.2)
> 10 February 2023
- chore(release): version 1.18.2 [`#2700`](https://github.com/gradido/gradido/pull/2700)
- fix(admin): deny contribution button to left [`#2699`](https://github.com/gradido/gradido/pull/2699) - fix(admin): deny contribution button to left [`#2699`](https://github.com/gradido/gradido/pull/2699)
#### [1.18.1](https://github.com/gradido/gradido/compare/1.18.0...1.18.1) #### [1.18.1](https://github.com/gradido/gradido/compare/1.18.0...1.18.1)

View File

@ -1,11 +1,17 @@
module.exports = { module.exports = {
verbose: true, verbose: true,
collectCoverage: true,
collectCoverageFrom: [ collectCoverageFrom: [
'src/**/*.{js,vue}', 'src/**/*.{js,vue}',
'!**/node_modules/**', '!**/node_modules/**',
'!src/assets/**', '!src/assets/**',
'!**/?(*.)+(spec|test).js?(x)', '!**/?(*.)+(spec|test).js?(x)',
], ],
coverageThreshold: {
global: {
lines: 97,
},
},
moduleFileExtensions: [ moduleFileExtensions: [
'js', 'js',
// 'jsx', // 'jsx',

View File

@ -3,7 +3,7 @@
"description": "Administraion Interface for Gradido", "description": "Administraion Interface for Gradido",
"main": "index.js", "main": "index.js",
"author": "Moriz Wahl", "author": "Moriz Wahl",
"version": "1.18.2", "version": "1.19.1",
"license": "Apache-2.0", "license": "Apache-2.0",
"private": false, "private": false,
"scripts": { "scripts": {
@ -14,7 +14,7 @@
"analyse-bundle": "yarn build && webpack-bundle-analyzer dist/webpack.stats.json", "analyse-bundle": "yarn build && webpack-bundle-analyzer dist/webpack.stats.json",
"lint": "eslint --max-warnings=0 --ext .js,.vue,.json .", "lint": "eslint --max-warnings=0 --ext .js,.vue,.json .",
"stylelint": "stylelint --max-warnings=0 '**/*.{scss,vue}'", "stylelint": "stylelint --max-warnings=0 '**/*.{scss,vue}'",
"test": "cross-env TZ=UTC jest --coverage", "test": "cross-env TZ=UTC jest",
"locales": "scripts/sort.sh" "locales": "scripts/sort.sh"
}, },
"dependencies": { "dependencies": {

View File

@ -10,6 +10,7 @@ describe('ContributionMessagesList', () => {
const propsData = { const propsData = {
contributionId: 42, contributionId: 42,
contributionState: 'PENDING',
} }
const mocks = { const mocks = {

View File

@ -1,17 +1,18 @@
<template> <template>
<div class="contribution-messages-list"> <div class="contribution-messages-list">
<b-container> <b-container>
{{ messages.lenght }}
<div v-for="message in messages" v-bind:key="message.id"> <div v-for="message in messages" v-bind:key="message.id">
<contribution-messages-list-item :message="message" /> <contribution-messages-list-item :message="message" />
</div> </div>
</b-container> </b-container>
<contribution-messages-formular <div v-if="contributionState === 'PENDING' || contributionState === 'IN_PROGRESS'">
:contributionId="contributionId" <contribution-messages-formular
@get-list-contribution-messages="getListContributionMessages" :contributionId="contributionId"
@update-state="updateState" @get-list-contribution-messages="getListContributionMessages"
/> @update-state="updateState"
/>
</div>
</div> </div>
</template> </template>
<script> <script>
@ -30,6 +31,10 @@ export default {
type: Number, type: Number,
required: true, required: true,
}, },
contributionState: {
type: String,
required: true,
},
}, },
data() { data() {
return { return {

View File

@ -1,8 +1,8 @@
<template> <template>
<div class="component-nabvar"> <div class="component-nabvar">
<b-navbar toggleable="md" type="dark" variant="success" class="p-3"> <b-navbar toggleable="md" type="dark" variant="success">
<b-navbar-brand to="/"> <b-navbar-brand class="mb-2" to="/">
<img src="img/brand/gradido_logo_w.png" class="navbar-brand-img" alt="..." /> <img src="img/brand/gradido_logo_w.png" class="navbar-brand-img pl-2" alt="..." />
</b-navbar-brand> </b-navbar-brand>
<b-navbar-toggle target="nav-collapse"></b-navbar-toggle> <b-navbar-toggle target="nav-collapse"></b-navbar-toggle>
@ -10,7 +10,7 @@
<b-collapse id="nav-collapse" is-nav> <b-collapse id="nav-collapse" is-nav>
<b-navbar-nav> <b-navbar-nav>
<b-nav-item to="/user">{{ $t('navbar.user_search') }}</b-nav-item> <b-nav-item to="/user">{{ $t('navbar.user_search') }}</b-nav-item>
<b-nav-item class="bg-color-creation p-1" to="/creation-confirm"> <b-nav-item class="bg-color-creation" to="/creation-confirm">
{{ $t('creation') }} {{ $t('creation') }}
<b-badge v-show="$store.state.openCreations > 0" variant="danger"> <b-badge v-show="$store.state.openCreations > 0" variant="danger">
{{ $store.state.openCreations }} {{ $store.state.openCreations }}
@ -52,6 +52,5 @@ export default {
<style> <style>
.navbar-brand-img { .navbar-brand-img {
height: 2rem; height: 2rem;
padding-left: 10px;
} }
</style> </style>

View File

@ -13,17 +13,19 @@
<b-icon :icon="getStatusIcon(row.item.state)"></b-icon> <b-icon :icon="getStatusIcon(row.item.state)"></b-icon>
</template> </template>
<template #cell(bookmark)="row"> <template #cell(bookmark)="row">
<b-button <div v-if="!myself(row.item)">
variant="danger" <b-button
size="md" variant="danger"
@click="$emit('show-overlay', row.item, 'delete')" size="md"
class="mr-2" @click="$emit('show-overlay', row.item, 'delete')"
> class="mr-2"
<b-icon icon="trash" variant="light"></b-icon> >
</b-button> <b-icon icon="trash" variant="light"></b-icon>
</b-button>
</div>
</template> </template>
<template #cell(editCreation)="row"> <template #cell(editCreation)="row">
<div v-if="$store.state.moderator.id !== row.item.userId"> <div v-if="!myself(row.item)">
<b-button <b-button
v-if="row.item.moderator" v-if="row.item.moderator"
variant="info" variant="info"
@ -36,30 +38,26 @@
<b-button v-else @click="rowToggleDetails(row, 0)"> <b-button v-else @click="rowToggleDetails(row, 0)">
<b-icon icon="chat-dots"></b-icon> <b-icon icon="chat-dots"></b-icon>
<b-icon <b-icon
v-if="row.item.state === 'PENDING' && row.item.messageCount > 0" v-if="row.item.state === 'PENDING' && row.item.messagesCount > 0"
icon="exclamation-circle-fill" icon="exclamation-circle-fill"
variant="warning" variant="warning"
></b-icon> ></b-icon>
<b-icon <b-icon
v-if="row.item.state === 'IN_PROGRESS' && row.item.messageCount > 0" v-if="row.item.state === 'IN_PROGRESS' && row.item.messagesCount > 0"
icon="question-diamond" icon="question-diamond"
variant="light" variant="warning"
class="pl-1"
></b-icon> ></b-icon>
</b-button> </b-button>
</div> </div>
</template> </template>
<template #cell(reActive)>
<b-button variant="warning" size="md" class="mr-2">
<b-icon icon="arrow-up" variant="light"></b-icon>
</b-button>
</template>
<template #cell(chatCreation)="row"> <template #cell(chatCreation)="row">
<b-button v-if="row.item.messagesCount > 0" @click="rowToggleDetails(row, 0)"> <b-button v-if="row.item.messagesCount > 0" @click="rowToggleDetails(row, 0)">
<b-icon icon="chat-dots"></b-icon> <b-icon icon="chat-dots"></b-icon>
</b-button> </b-button>
</template> </template>
<template #cell(deny)="row"> <template #cell(deny)="row">
<div v-if="$store.state.moderator.id !== row.item.userId"> <div v-if="!myself(row.item)">
<b-button <b-button
variant="warning" variant="warning"
size="md" size="md"
@ -71,7 +69,7 @@
</div> </div>
</template> </template>
<template #cell(confirm)="row"> <template #cell(confirm)="row">
<div v-if="$store.state.moderator.id !== row.item.userId"> <div v-if="!myself(row.item)">
<b-button <b-button
variant="success" variant="success"
size="md" size="md"
@ -104,6 +102,7 @@
<div v-else> <div v-else>
<contribution-messages-list <contribution-messages-list
:contributionId="row.item.id" :contributionId="row.item.id"
:contributionState="row.item.state"
@update-state="updateState" @update-state="updateState"
@update-user-data="updateUserData" @update-user-data="updateUserData"
/> />
@ -158,13 +157,22 @@ export default {
} }
}, },
methods: { methods: {
myself(item) {
return (
`${item.firstName} ${item.lastName}` ===
`${this.$store.state.moderator.firstName} ${this.$store.state.moderator.lastName}`
)
},
getStatusIcon(status) { getStatusIcon(status) {
return iconMap[status] ? iconMap[status] : 'default-icon' return iconMap[status] ? iconMap[status] : 'default-icon'
}, },
rowClass(item, type) { rowClass(item, type) {
if (!item || type !== 'row') return if (!item || type !== 'row') return
if (item.state === 'CONFIRMED') return 'table-success' if (item.state === 'CONFIRMED') return 'table-success'
if (item.state === 'DENIED') return 'table-info' if (item.state === 'DENIED') return 'table-warning'
if (item.state === 'DELETED') return 'table-danger'
if (item.state === 'IN_PROGRESS') return 'table-primary'
if (item.state === 'PENDING') return 'table-primary'
}, },
updateCreationData(data) { updateCreationData(data) {
const row = data.row const row = data.row

View File

@ -1,7 +1,7 @@
import gql from 'graphql-tag' import gql from 'graphql-tag'
export const adminCreateContributionMessage = gql` export const adminCreateContributionMessage = gql`
mutation ($contributionId: Float!, $message: String!) { mutation ($contributionId: Int!, $message: String!) {
adminCreateContributionMessage(contributionId: $contributionId, message: $message) { adminCreateContributionMessage(contributionId: $contributionId, message: $message) {
id id
message message

View File

@ -1,7 +1,7 @@
import gql from 'graphql-tag' import gql from 'graphql-tag'
export const listContributionMessages = gql` export const listContributionMessages = gql`
query ($contributionId: Float!, $pageSize: Int = 25, $currentPage: Int = 1, $order: Order = ASC) { query ($contributionId: Int!, $pageSize: Int = 25, $currentPage: Int = 1, $order: Order = ASC) {
listContributionMessages( listContributionMessages(
contributionId: $contributionId contributionId: $contributionId
pageSize: $pageSize pageSize: $pageSize

View File

@ -63,7 +63,6 @@
"deleted_user": "Alle gelöschten Nutzer", "deleted_user": "Alle gelöschten Nutzer",
"delete_user": "Nutzer löschen", "delete_user": "Nutzer löschen",
"deny": "Ablehnen", "deny": "Ablehnen",
"edit": "Bearbeiten",
"enabled": "aktiviert", "enabled": "aktiviert",
"error": "Fehler", "error": "Fehler",
"expired": "abgelaufen", "expired": "abgelaufen",
@ -101,7 +100,6 @@
"message": { "message": {
"request": "Die Anfrage wurde gesendet." "request": "Die Anfrage wurde gesendet."
}, },
"mod": "Mod",
"moderator": "Moderator", "moderator": "Moderator",
"name": "Name", "name": "Name",
"navbar": { "navbar": {

View File

@ -34,11 +34,11 @@
"all": "All", "all": "All",
"confirms": "Confirmed", "confirms": "Confirmed",
"deleted": "Deleted", "deleted": "Deleted",
"denied": "Denied", "denied": "Rejected",
"open": "Open" "open": "Open"
}, },
"created": "Confirmed", "created": "Created for",
"createdAt": "Created", "createdAt": "Created at",
"creation": "Creation", "creation": "Creation",
"creationList": "Creation list", "creationList": "Creation list",
"creation_form": { "creation_form": {
@ -53,7 +53,7 @@
"toasted": "Open creation ({value} GDD) for {email} has been saved and is ready for confirmation.", "toasted": "Open creation ({value} GDD) for {email} has been saved and is ready for confirmation.",
"toasted_created": "Creation has been successfully saved", "toasted_created": "Creation has been successfully saved",
"toasted_delete": "Open creation has been deleted", "toasted_delete": "Open creation has been deleted",
"toasted_denied": "Open creation has been denied", "toasted_denied": "Open creation has been rejected",
"toasted_update": "Open creation {value} GDD) for {email} has been changed and is ready for confirmation.", "toasted_update": "Open creation {value} GDD) for {email} has been changed and is ready for confirmation.",
"update_creation": "Creation update" "update_creation": "Creation update"
}, },
@ -63,7 +63,6 @@
"deleted_user": "All deleted user", "deleted_user": "All deleted user",
"delete_user": "Delete user", "delete_user": "Delete user",
"deny": "Reject", "deny": "Reject",
"edit": "Edit",
"enabled": "enabled", "enabled": "enabled",
"error": "Error", "error": "Error",
"expired": "expired", "expired": "expired",
@ -87,7 +86,7 @@
"transactionlist": { "transactionlist": {
"confirmed": "When was it confirmed by a moderator / admin.", "confirmed": "When was it confirmed by a moderator / admin.",
"periods": "For what period was it submitted by the member.", "periods": "For what period was it submitted by the member.",
"state": "[PENDING = submitted, DELETED = deleted, IN_PROGRESS = in dialogue with moderator, DENIED = denied, CONFIRMED = confirmed]", "state": "[PENDING = submitted, DELETED = deleted, IN_PROGRESS = in dialogue with moderator, DENIED = rejected, CONFIRMED = confirmed]",
"submitted": "When was it submitted by the member" "submitted": "When was it submitted by the member"
} }
}, },
@ -101,7 +100,6 @@
"message": { "message": {
"request": "Request has been sent." "request": "Request has been sent."
}, },
"mod": "Mod",
"moderator": "Moderator", "moderator": "Moderator",
"name": "Name", "name": "Name",
"navbar": { "navbar": {

View File

@ -5,25 +5,37 @@
<b-tabs v-model="tabIndex" content-class="mt-3" fill> <b-tabs v-model="tabIndex" content-class="mt-3" fill>
<b-tab active :title-link-attributes="{ 'data-test': 'open' }"> <b-tab active :title-link-attributes="{ 'data-test': 'open' }">
<template #title> <template #title>
<b-icon icon="bell-fill" variant="primary"></b-icon>
{{ $t('contributions.open') }} {{ $t('contributions.open') }}
<b-badge v-if="$store.state.openCreations > 0" variant="danger"> <b-badge v-if="$store.state.openCreations > 0" variant="danger">
{{ $store.state.openCreations }} {{ $store.state.openCreations }}
</b-badge> </b-badge>
</template> </template>
</b-tab> </b-tab>
<b-tab <b-tab :title-link-attributes="{ 'data-test': 'confirmed' }">
:title="$t('contributions.confirms')" <template #title>
:title-link-attributes="{ 'data-test': 'confirmed' }" <b-icon icon="check" variant="success"></b-icon>
/> {{ $t('contributions.confirms') }}
<b-tab </template>
:title="$t('contributions.denied')" </b-tab>
:title-link-attributes="{ 'data-test': 'denied' }" <b-tab :title-link-attributes="{ 'data-test': 'denied' }">
/> <template #title>
<b-tab <b-icon icon="x-circle" variant="warning"></b-icon>
:title="$t('contributions.deleted')" {{ $t('contributions.denied') }}
:title-link-attributes="{ 'data-test': 'deleted' }" </template>
/> </b-tab>
<b-tab :title="$t('contributions.all')" :title-link-attributes="{ 'data-test': 'all' }" /> <b-tab :title-link-attributes="{ 'data-test': 'deleted' }">
<template #title>
<b-icon icon="trash" variant="danger"></b-icon>
{{ $t('contributions.deleted') }}
</template>
</b-tab>
<b-tab :title-link-attributes="{ 'data-test': 'all' }">
<template #title>
<b-icon icon="list"></b-icon>
{{ $t('contributions.all') }}
</template>
</b-tab>
</b-tabs> </b-tabs>
</div> </div>
<open-creations-table <open-creations-table
@ -172,6 +184,9 @@ export default {
this.items.find((obj) => obj.id === id).messagesCount++ this.items.find((obj) => obj.id === id).messagesCount++
this.items.find((obj) => obj.id === id).state = 'IN_PROGRESS' this.items.find((obj) => obj.id === id).state = 'IN_PROGRESS'
}, },
formatDateOrDash(value) {
return value ? this.$d(new Date(value), 'short') : '—'
},
}, },
computed: { computed: {
fields() { fields() {
@ -180,7 +195,6 @@ export default {
// open contributions // open contributions
{ key: 'bookmark', label: this.$t('delete') }, { key: 'bookmark', label: this.$t('delete') },
{ key: 'deny', label: this.$t('deny') }, { key: 'deny', label: this.$t('deny') },
{ key: 'email', label: this.$t('e_mail') },
{ key: 'firstName', label: this.$t('firstname') }, { key: 'firstName', label: this.$t('firstname') },
{ key: 'lastName', label: this.$t('lastname') }, { key: 'lastName', label: this.$t('lastname') },
{ {
@ -195,11 +209,11 @@ export default {
key: 'contributionDate', key: 'contributionDate',
label: this.$t('created'), label: this.$t('created'),
formatter: (value) => { formatter: (value) => {
return this.$d(new Date(value), 'short') return this.formatDateOrDash(value)
}, },
}, },
{ key: 'moderator', label: this.$t('moderator') }, { key: 'moderator', label: this.$t('moderator') },
{ key: 'editCreation', label: this.$t('edit') }, { key: 'editCreation', label: this.$t('chat') },
{ key: 'confirm', label: this.$t('save') }, { key: 'confirm', label: this.$t('save') },
], ],
[ [
@ -218,28 +232,28 @@ export default {
key: 'contributionDate', key: 'contributionDate',
label: this.$t('created'), label: this.$t('created'),
formatter: (value) => { formatter: (value) => {
return this.$d(new Date(value), 'short') return this.formatDateOrDash(value)
}, },
}, },
{ {
key: 'createdAt', key: 'createdAt',
label: this.$t('createdAt'), label: this.$t('createdAt'),
formatter: (value) => { formatter: (value) => {
return this.$d(new Date(value), 'short') return this.formatDateOrDash(value)
}, },
}, },
{ {
key: 'confirmedAt', key: 'confirmedAt',
label: this.$t('contributions.confirms'), label: this.$t('contributions.confirms'),
formatter: (value) => { formatter: (value) => {
return this.$d(new Date(value), 'short') return this.formatDateOrDash(value)
}, },
}, },
{ key: 'confirmedBy', label: this.$t('moderator') },
{ key: 'chatCreation', label: this.$t('chat') }, { key: 'chatCreation', label: this.$t('chat') },
], ],
[ [
// denied contributions // denied contributions
{ key: 'reActive', label: 'reActive' },
{ key: 'firstName', label: this.$t('firstname') }, { key: 'firstName', label: this.$t('firstname') },
{ key: 'lastName', label: this.$t('lastname') }, { key: 'lastName', label: this.$t('lastname') },
{ {
@ -254,29 +268,28 @@ export default {
key: 'contributionDate', key: 'contributionDate',
label: this.$t('created'), label: this.$t('created'),
formatter: (value) => { formatter: (value) => {
return this.$d(new Date(value), 'short') return this.formatDateOrDash(value)
}, },
}, },
{ {
key: 'createdAt', key: 'createdAt',
label: this.$t('createdAt'), label: this.$t('createdAt'),
formatter: (value) => { formatter: (value) => {
return this.$d(new Date(value), 'short') return this.formatDateOrDash(value)
}, },
}, },
{ {
key: 'deniedAt', key: 'deniedAt',
label: this.$t('contributions.denied'), label: this.$t('contributions.denied'),
formatter: (value) => { formatter: (value) => {
return this.$d(new Date(value), 'short') return this.formatDateOrDash(value)
}, },
}, },
{ key: 'deniedBy', label: this.$t('mod') }, { key: 'deniedBy', label: this.$t('moderator') },
{ key: 'chatCreation', label: this.$t('chat') }, { key: 'chatCreation', label: this.$t('chat') },
], ],
[ [
// deleted contributions // deleted contributions
{ key: 'reActive', label: 'reActive' },
{ key: 'firstName', label: this.$t('firstname') }, { key: 'firstName', label: this.$t('firstname') },
{ key: 'lastName', label: this.$t('lastname') }, { key: 'lastName', label: this.$t('lastname') },
{ {
@ -291,29 +304,29 @@ export default {
key: 'contributionDate', key: 'contributionDate',
label: this.$t('created'), label: this.$t('created'),
formatter: (value) => { formatter: (value) => {
return this.$d(new Date(value), 'short') return this.formatDateOrDash(value)
}, },
}, },
{ {
key: 'createdAt', key: 'createdAt',
label: this.$t('createdAt'), label: this.$t('createdAt'),
formatter: (value) => { formatter: (value) => {
return this.$d(new Date(value), 'short') return this.formatDateOrDash(value)
}, },
}, },
{ {
key: 'deletedAt', key: 'deletedAt',
label: this.$t('contributions.deleted'), label: this.$t('contributions.deleted'),
formatter: (value) => { formatter: (value) => {
return this.$d(new Date(value), 'short') return this.formatDateOrDash(value)
}, },
}, },
{ key: 'deletedBy', label: this.$t('mod') }, { key: 'deletedBy', label: this.$t('moderator') },
{ key: 'chatCreation', label: this.$t('chat') }, { key: 'chatCreation', label: this.$t('chat') },
], ],
[ [
// all contributions // all contributions
{ key: 'state', label: 'state' }, { key: 'state', label: this.$t('status') },
{ key: 'firstName', label: this.$t('firstname') }, { key: 'firstName', label: this.$t('firstname') },
{ key: 'lastName', label: this.$t('lastname') }, { key: 'lastName', label: this.$t('lastname') },
{ {
@ -328,24 +341,24 @@ export default {
key: 'contributionDate', key: 'contributionDate',
label: this.$t('created'), label: this.$t('created'),
formatter: (value) => { formatter: (value) => {
return this.$d(new Date(value), 'short') return this.formatDateOrDash(value)
}, },
}, },
{ {
key: 'createdAt', key: 'createdAt',
label: this.$t('createdAt'), label: this.$t('createdAt'),
formatter: (value) => { formatter: (value) => {
return this.$d(new Date(value), 'short') return this.formatDateOrDash(value)
}, },
}, },
{ {
key: 'confirmedAt', key: 'confirmedAt',
label: this.$t('contributions.confirms'), label: this.$t('contributions.confirms'),
formatter: (value) => { formatter: (value) => {
return this.$d(new Date(value), 'short') return this.formatDateOrDash(value)
}, },
}, },
{ key: 'confirmedBy', label: this.$t('mod') }, { key: 'confirmedBy', label: this.$t('moderator') },
{ key: 'chatCreation', label: this.$t('chat') }, { key: 'chatCreation', label: this.$t('chat') },
], ],
][this.tabIndex] ][this.tabIndex]
@ -397,6 +410,9 @@ export default {
update({ adminListAllContributions }) { update({ adminListAllContributions }) {
this.rows = adminListAllContributions.contributionCount this.rows = adminListAllContributions.contributionCount
this.items = adminListAllContributions.contributionList this.items = adminListAllContributions.contributionList
if (this.statusFilter === FILTER_TAB_MAP[0]) {
this.$store.commit('setOpenCreations', adminListAllContributions.contributionCount)
}
}, },
error({ message }) { error({ message }) {
this.toastError(message) this.toastError(message)

View File

@ -1,5 +1,5 @@
# Server # Server
JWT_EXPIRES_IN=1m JWT_EXPIRES_IN=2m
# Email # Email
EMAIL=true EMAIL=true

View File

@ -2,16 +2,10 @@ module.exports = {
root: true, root: true,
env: { env: {
node: true, node: true,
// jest: true,
}, },
parser: '@typescript-eslint/parser', parser: '@typescript-eslint/parser',
plugins: ['prettier', '@typescript-eslint' /*, 'jest' */], plugins: ['prettier', '@typescript-eslint', 'type-graphql'],
extends: [ extends: ['standard', 'eslint:recommended', 'plugin:prettier/recommended'],
'standard',
'eslint:recommended',
'plugin:prettier/recommended',
'plugin:@typescript-eslint/recommended',
],
// add your custom rules here // add your custom rules here
rules: { rules: {
'no-console': ['error'], 'no-console': ['error'],
@ -23,4 +17,28 @@ module.exports = {
}, },
], ],
}, },
overrides: [
// only for ts files
{
files: ['*.ts'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:type-graphql/recommended',
],
rules: {
// allow explicitly defined dangling promises
'@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }],
'no-void': ['error', { allowAsStatement: true }],
// ignore prefer-regexp-exec rule to allow string.match(regex)
'@typescript-eslint/prefer-regexp-exec': 'off',
},
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
// this is to properly reference the referenced project database without requirement of compiling it
EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true,
},
},
],
} }

View File

@ -4,6 +4,11 @@ module.exports = {
preset: 'ts-jest', preset: 'ts-jest',
collectCoverage: true, collectCoverage: true,
collectCoverageFrom: ['src/**/*.ts', '!**/node_modules/**', '!src/seeds/**', '!build/**'], collectCoverageFrom: ['src/**/*.ts', '!**/node_modules/**', '!src/seeds/**', '!build/**'],
coverageThreshold: {
global: {
lines: 80,
},
},
setupFiles: ['<rootDir>/test/testSetup.ts'], setupFiles: ['<rootDir>/test/testSetup.ts'],
setupFilesAfterEnv: ['<rootDir>/test/extensions.ts'], setupFilesAfterEnv: ['<rootDir>/test/extensions.ts'],
modulePathIgnorePatterns: ['<rootDir>/build/'], modulePathIgnorePatterns: ['<rootDir>/build/'],

View File

@ -1,6 +1,6 @@
{ {
"name": "gradido-backend", "name": "gradido-backend",
"version": "1.18.2", "version": "1.19.1",
"description": "Gradido unified backend providing an API-Service for Gradido Transactions", "description": "Gradido unified backend providing an API-Service for Gradido Transactions",
"main": "src/index.ts", "main": "src/index.ts",
"repository": "https://github.com/gradido/gradido/backend", "repository": "https://github.com/gradido/gradido/backend",
@ -13,7 +13,7 @@
"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 --ext .js,.ts .",
"test": "cross-env TZ=UTC NODE_ENV=development jest --runInBand --coverage --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",
"locales": "scripts/sort.sh" "locales": "scripts/sort.sh"
@ -65,6 +65,7 @@
"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",
"faker": "^5.5.3", "faker": "^5.5.3",
"jest": "^27.2.4", "jest": "^27.2.4",
"nodemon": "^2.0.7", "nodemon": "^2.0.7",

View File

@ -1,16 +1,19 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import axios from 'axios' import axios from 'axios'
import { backendLogger as logger } from '@/server/logger' import { backendLogger as logger } from '@/server/logger'
import LogError from '@/server/LogError'
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
export const apiPost = async (url: string, payload: unknown): Promise<any> => { export const apiPost = async (url: string, payload: unknown): Promise<any> => {
logger.trace('POST: url=' + url + ' payload=' + payload) logger.trace('POST', url, payload)
return axios return axios
.post(url, payload) .post(url, payload)
.then((result) => { .then((result) => {
logger.trace('POST-Response: result=' + result) logger.trace('POST-Response', result)
if (result.status !== 200) { if (result.status !== 200) {
throw new Error('HTTP Status Error ' + result.status) throw new LogError('HTTP Status Error', result.status)
} }
if (result.data.state !== 'success') { if (result.data.state !== 'success') {
throw new Error(result.data.msg) throw new Error(result.data.msg)
@ -28,9 +31,9 @@ export const apiGet = async (url: string): Promise<any> => {
return axios return axios
.get(url) .get(url)
.then((result) => { .then((result) => {
logger.trace('GET-Response: result=' + result) logger.trace('GET-Response', result)
if (result.status !== 200) { if (result.status !== 200) {
throw new Error('HTTP Status Error ' + result.status) throw new LogError('HTTP Status Error', result.status)
} }
if (!['success', 'warning'].includes(result.data.state)) { if (!['success', 'warning'].includes(result.data.state)) {
throw new Error(result.data.msg) throw new Error(result.data.msg)

View File

@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* 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 { KlicktippConnector } from './klicktippConnector' import { KlicktippConnector } from './klicktippConnector'

View File

@ -1,3 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* 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 axios, { AxiosRequestConfig, Method } from 'axios' import axios, { AxiosRequestConfig, Method } from 'axios'

View File

@ -54,4 +54,5 @@ export enum RIGHTS {
UPDATE_CONTRIBUTION_LINK = 'UPDATE_CONTRIBUTION_LINK', UPDATE_CONTRIBUTION_LINK = 'UPDATE_CONTRIBUTION_LINK',
ADMIN_CREATE_CONTRIBUTION_MESSAGE = 'ADMIN_CREATE_CONTRIBUTION_MESSAGE', ADMIN_CREATE_CONTRIBUTION_MESSAGE = 'ADMIN_CREATE_CONTRIBUTION_MESSAGE',
DENY_CONTRIBUTION = 'DENY_CONTRIBUTION', DENY_CONTRIBUTION = 'DENY_CONTRIBUTION',
ADMIN_OPEN_CREATIONS = 'ADMIN_OPEN_CREATIONS',
} }

View File

@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/unbound-method */
import { createTransport } from 'nodemailer' import { createTransport } from 'nodemailer'
import { logger, i18n } from '@test/testSetup' import { logger, i18n } from '@test/testSetup'
import CONFIG from '@/config' import CONFIG from '@/config'

View File

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/restrict-template-expressions */
import CONFIG from '@/config' import CONFIG from '@/config'
import { backendLogger as logger } from '@/server/logger' import { backendLogger as logger } from '@/server/logger'
import path from 'path' import path from 'path'

View File

@ -1,5 +1,8 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* 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 { testEnvironment } from '@test/helpers'
import { logger, i18n as localization } from '@test/testSetup' import { logger, i18n as localization } from '@test/testSetup'

View File

@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* 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 { backendLogger as logger } from '@/server/logger'
import { Community as DbCommunity } from '@entity/Community' import { Community as DbCommunity } from '@entity/Community'

View File

@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* 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 { backendLogger as logger } from '@/server/logger'
import { Community as DbCommunity } from '@entity/Community' import { Community as DbCommunity } from '@entity/Community'

View File

@ -1,3 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* 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 */
@ -150,7 +154,8 @@ describe('validate Communities', () => {
}) })
it('logs unsupported api for community with api 2_0 ', () => { it('logs unsupported api for community with api 2_0 ', () => {
expect(logger.warn).toBeCalledWith( expect(logger.warn).toBeCalledWith(
`Federation: dbCom: ${dbCom.id} with unsupported apiVersion=2_0; supported versions=1_0,1_1`, `Federation: dbCom: ${dbCom.id} with unsupported apiVersion=2_0; supported versions`,
['1_0', '1_1'],
) )
}) })
}) })

View File

@ -8,14 +8,14 @@ import { backendLogger as logger } from '@/server/logger'
import { ApiVersionType } from './enum/apiVersionType' import { ApiVersionType } from './enum/apiVersionType'
import LogError from '@/server/LogError' import LogError from '@/server/LogError'
export async function startValidateCommunities(timerInterval: number): Promise<void> { export function startValidateCommunities(timerInterval: number): void {
logger.info( logger.info(
`Federation: startValidateCommunities loop with an interval of ${timerInterval} ms...`, `Federation: startValidateCommunities loop with an interval of ${timerInterval} ms...`,
) )
// TODO: replace the timer-loop by an event-based communication to verify announced foreign communities // TODO: replace the timer-loop by an event-based communication to verify announced foreign communities
// better to use setTimeout twice than setInterval once -> see https://javascript.info/settimeout-setinterval // better to use setTimeout twice than setInterval once -> see https://javascript.info/settimeout-setinterval
setTimeout(function run() { setTimeout(function run() {
validateCommunities() void validateCommunities()
setTimeout(run, timerInterval) setTimeout(run, timerInterval)
}, timerInterval) }, timerInterval)
} }
@ -27,8 +27,8 @@ export async function validateCommunities(): Promise<void> {
.getMany() .getMany()
logger.debug(`Federation: found ${dbCommunities.length} dbCommunities`) logger.debug(`Federation: found ${dbCommunities.length} dbCommunities`)
dbCommunities.forEach(async function (dbCom) { for (const dbCom of dbCommunities) {
logger.debug(`Federation: dbCom: ${JSON.stringify(dbCom)}`) logger.debug('Federation: dbCom', dbCom)
const apiValueStrings: string[] = Object.values(ApiVersionType) const apiValueStrings: string[] = Object.values(ApiVersionType)
logger.debug(`suppported ApiVersions=`, apiValueStrings) logger.debug(`suppported ApiVersions=`, apiValueStrings)
if (apiValueStrings.includes(dbCom.apiVersion)) { if (apiValueStrings.includes(dbCom.apiVersion)) {
@ -38,11 +38,13 @@ export async function validateCommunities(): Promise<void> {
try { try {
const pubKey = await invokeVersionedRequestGetPublicKey(dbCom) const pubKey = await invokeVersionedRequestGetPublicKey(dbCom)
logger.info( logger.info(
`Federation: received publicKey=${pubKey} from endpoint=${dbCom.endPoint}/${dbCom.apiVersion}`, 'Federation: received publicKey from endpoint',
pubKey,
`${dbCom.endPoint}/${dbCom.apiVersion}`,
) )
if (pubKey && pubKey === dbCom.publicKey.toString('hex')) { if (pubKey && pubKey === dbCom.publicKey.toString('hex')) {
logger.info(`Federation: matching publicKey: ${pubKey}`) logger.info(`Federation: matching publicKey: ${pubKey}`)
DbCommunity.update({ id: dbCom.id }, { verifiedAt: new Date() }) await DbCommunity.update({ id: dbCom.id }, { verifiedAt: new Date() })
logger.debug(`Federation: updated dbCom: ${JSON.stringify(dbCom)}`) logger.debug(`Federation: updated dbCom: ${JSON.stringify(dbCom)}`)
} }
/* /*
@ -58,10 +60,11 @@ export async function validateCommunities(): Promise<void> {
} }
} else { } else {
logger.warn( logger.warn(
`Federation: dbCom: ${dbCom.id} with unsupported apiVersion=${dbCom.apiVersion}; supported versions=${apiValueStrings}`, `Federation: dbCom: ${dbCom.id} with unsupported apiVersion=${dbCom.apiVersion}; supported versions`,
apiValueStrings,
) )
} }
}) }
} }
function isLogError(err: unknown) { function isLogError(err: unknown) {

View File

@ -22,7 +22,7 @@ export default class ContributionLinkArgs {
validTo?: string | null validTo?: string | null
@Field(() => Decimal, { nullable: true }) @Field(() => Decimal, { nullable: true })
maxAmountPerMonth: Decimal | null maxAmountPerMonth?: Decimal | null
@Field(() => Int) @Field(() => Int)
maxPerCycle: number maxPerCycle: number

View File

@ -1,9 +1,9 @@
import { ArgsType, Field, InputType } from 'type-graphql' import { ArgsType, Field, Int, InputType } from 'type-graphql'
@InputType() @InputType()
@ArgsType() @ArgsType()
export default class ContributionMessageArgs { export default class ContributionMessageArgs {
@Field(() => Number) @Field(() => Int)
contributionId: number contributionId: number
@Field(() => String) @Field(() => String)

View File

@ -11,11 +11,11 @@ export default class CreateUserArgs {
@Field(() => String) @Field(() => String)
lastName: string lastName: string
@Field(() => String) @Field(() => String, { nullable: true })
language?: string // Will default to DEFAULT_LANGUAGE language?: string | null
@Field(() => Int, { nullable: true }) @Field(() => Int, { nullable: true })
publisherId: number publisherId?: number | null
@Field(() => String, { nullable: true }) @Field(() => String, { nullable: true })
redeemCode?: string | null redeemCode?: string | null

View File

@ -1,3 +1,4 @@
/* eslint-disable type-graphql/invalid-nullable-input-type */
import { ArgsType, Field, Int } from 'type-graphql' import { ArgsType, Field, Int } from 'type-graphql'
import { Order } from '@enum/Order' import { Order } from '@enum/Order'

View File

@ -7,11 +7,14 @@ export default class SearchUsersArgs {
searchText: string searchText: string
@Field(() => Int, { nullable: true }) @Field(() => Int, { nullable: true })
// eslint-disable-next-line type-graphql/invalid-nullable-input-type
currentPage?: number currentPage?: number
@Field(() => Int, { nullable: true }) @Field(() => Int, { nullable: true })
// eslint-disable-next-line type-graphql/invalid-nullable-input-type
pageSize?: number pageSize?: number
// eslint-disable-next-line type-graphql/wrong-decorator-signature
@Field(() => SearchUsersFilters, { nullable: true, defaultValue: null }) @Field(() => SearchUsersFilters, { nullable: true, defaultValue: null })
filters: SearchUsersFilters filters?: SearchUsersFilters | null
} }

View File

@ -3,8 +3,8 @@ import { Field, InputType } from 'type-graphql'
@InputType() @InputType()
export default class SearchUsersFilters { export default class SearchUsersFilters {
@Field(() => Boolean, { nullable: true, defaultValue: null }) @Field(() => Boolean, { nullable: true, defaultValue: null })
byActivated: boolean byActivated?: boolean | null
@Field(() => Boolean, { nullable: true, defaultValue: null }) @Field(() => Boolean, { nullable: true, defaultValue: null })
byDeleted: boolean byDeleted?: boolean | null
} }

View File

@ -1,13 +1,14 @@
/* eslint-disable type-graphql/invalid-nullable-input-type */
import { Field, InputType } from 'type-graphql' import { Field, InputType } from 'type-graphql'
@InputType() @InputType()
export default class TransactionLinkFilters { export default class TransactionLinkFilters {
@Field(() => Boolean, { nullable: true }) @Field(() => Boolean, { nullable: true })
withDeleted: boolean withDeleted?: boolean
@Field(() => Boolean, { nullable: true }) @Field(() => Boolean, { nullable: true })
withExpired: boolean withExpired?: boolean
@Field(() => Boolean, { nullable: true }) @Field(() => Boolean, { nullable: true })
withRedeemed: boolean withRedeemed?: boolean
} }

View File

@ -9,5 +9,5 @@ export default class UnsecureLoginArgs {
password: string password: string
@Field(() => Int, { nullable: true }) @Field(() => Int, { nullable: true })
publisherId: number publisherId?: number | null
} }

View File

@ -1,4 +1,4 @@
import { ArgsType, Field } from 'type-graphql' import { ArgsType, Field, Int } from 'type-graphql'
@ArgsType() @ArgsType()
export default class UpdateUserInfosArgs { export default class UpdateUserInfosArgs {
@ -11,8 +11,8 @@ export default class UpdateUserInfosArgs {
@Field({ nullable: true }) @Field({ nullable: true })
language?: string language?: string
@Field({ nullable: true }) @Field(() => Int, { nullable: true })
publisherId?: number publisherId?: number | null
@Field({ nullable: true }) @Field({ nullable: true })
password?: string password?: string

View File

@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
import { AuthChecker } from 'type-graphql' import { AuthChecker } from 'type-graphql'

View File

@ -1,4 +1,4 @@
import { ObjectType, Field } 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()
@ -19,14 +19,14 @@ export class Balance {
@Field(() => Decimal) @Field(() => Decimal)
balance: Decimal balance: Decimal
@Field(() => Number, { nullable: true }) @Field(() => Float, { nullable: true })
balanceGDT: number | null balanceGDT: number | null
// the count of all transactions // the count of all transactions
@Field(() => Number) @Field(() => Int)
count: number count: number
// the count of transaction links // the count of transaction links
@Field(() => Number) @Field(() => Int)
linkCount: number linkCount: number
} }

View File

@ -1,6 +1,8 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* 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 { ObjectType, Field } from 'type-graphql' import { ObjectType, Field, Int } from 'type-graphql'
@ObjectType() @ObjectType()
export class Community { export class Community {
@ -14,7 +16,7 @@ export class Community {
} }
} }
@Field(() => Number) @Field(() => Int)
id: number id: number
@Field(() => String) @Field(() => String)

View File

@ -1,9 +1,9 @@
import { ObjectType, Field } 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 {
@Field(() => Number) @Field(() => Int)
activeUsers: number activeUsers: number
@Field(() => Decimal) @Field(() => Decimal)
@ -15,13 +15,13 @@ export class DynamicStatisticsFields {
@ObjectType() @ObjectType()
export class CommunityStatistics { export class CommunityStatistics {
@Field(() => Number) @Field(() => Int)
allUsers: number allUsers: number
@Field(() => Number) @Field(() => Int)
totalUsers: number totalUsers: number
@Field(() => Number) @Field(() => Int)
deletedUsers: number deletedUsers: number
@Field(() => Decimal) @Field(() => Decimal)

View File

@ -23,7 +23,7 @@ export class Contribution {
this.deletedBy = contribution.deletedBy this.deletedBy = contribution.deletedBy
} }
@Field(() => Number) @Field(() => Int)
id: number id: number
@Field(() => String, { nullable: true }) @Field(() => String, { nullable: true })
@ -44,25 +44,25 @@ export class Contribution {
@Field(() => Date, { nullable: true }) @Field(() => Date, { nullable: true })
confirmedAt: Date | null confirmedAt: Date | null
@Field(() => Number, { nullable: true }) @Field(() => Int, { nullable: true })
confirmedBy: number | null confirmedBy: number | null
@Field(() => Date, { nullable: true }) @Field(() => Date, { nullable: true })
deniedAt: Date | null deniedAt: Date | null
@Field(() => Number, { nullable: true }) @Field(() => Int, { nullable: true })
deniedBy: number | null deniedBy: number | null
@Field(() => Date, { nullable: true }) @Field(() => Date, { nullable: true })
deletedAt: Date | null deletedAt: Date | null
@Field(() => Number, { nullable: true }) @Field(() => Int, { nullable: true })
deletedBy: number | null deletedBy: number | null
@Field(() => Date) @Field(() => Date)
contributionDate: Date contributionDate: Date
@Field(() => Number) @Field(() => Int)
messagesCount: number messagesCount: number
@Field(() => String) @Field(() => String)

View File

@ -21,7 +21,7 @@ export class ContributionLink {
this.link = CONFIG.COMMUNITY_REDEEM_CONTRIBUTION_URL.replace(/{code}/g, this.code) this.link = CONFIG.COMMUNITY_REDEEM_CONTRIBUTION_URL.replace(/{code}/g, this.code)
} }
@Field(() => Number) @Field(() => Int)
id: number id: number
@Field(() => Decimal) @Field(() => Decimal)

View File

@ -1,4 +1,4 @@
import { ObjectType, Field } from 'type-graphql' import { ObjectType, Field, Int } from 'type-graphql'
import { ContributionLink } from '@model/ContributionLink' import { ContributionLink } from '@model/ContributionLink'
@ObjectType() @ObjectType()
@ -6,6 +6,6 @@ export class ContributionLinkList {
@Field(() => [ContributionLink]) @Field(() => [ContributionLink])
links: ContributionLink[] links: ContributionLink[]
@Field(() => Number) @Field(() => Int)
count: number count: number
} }

View File

@ -1,4 +1,4 @@
import { Field, ObjectType } from 'type-graphql' import { Field, Int, ObjectType } from 'type-graphql'
import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage'
import { User } from '@entity/User' import { User } from '@entity/User'
@ -16,7 +16,7 @@ export class ContributionMessage {
this.isModerator = contributionMessage.isModerator this.isModerator = contributionMessage.isModerator
} }
@Field(() => Number) @Field(() => Int)
id: number id: number
@Field(() => String) @Field(() => String)
@ -26,7 +26,7 @@ export class ContributionMessage {
createdAt: Date createdAt: Date
@Field(() => Date, { nullable: true }) @Field(() => Date, { nullable: true })
updatedAt?: Date | null updatedAt: Date | null
@Field(() => String) @Field(() => String)
type: string type: string
@ -37,7 +37,7 @@ export class ContributionMessage {
@Field(() => String, { nullable: true }) @Field(() => String, { nullable: true })
userLastName: string | null userLastName: string | null
@Field(() => Number, { nullable: true }) @Field(() => Int, { nullable: true })
userId: number | null userId: number | null
@Field(() => Boolean) @Field(() => Boolean)
@ -45,7 +45,7 @@ export class ContributionMessage {
} }
@ObjectType() @ObjectType()
export class ContributionMessageListResult { export class ContributionMessageListResult {
@Field(() => Number) @Field(() => Int)
count: number count: number
@Field(() => [ContributionMessage]) @Field(() => [ContributionMessage])

View File

@ -1,6 +1,8 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* 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 { ObjectType, Field } from 'type-graphql' import { ObjectType, Field, Float, Int } from 'type-graphql'
import { GdtEntryType } from '@enum/GdtEntryType' import { GdtEntryType } from '@enum/GdtEntryType'
@ObjectType() @ObjectType()
@ -19,10 +21,10 @@ export class GdtEntry {
this.gdt = json.gdt this.gdt = json.gdt
} }
@Field(() => Number) @Field(() => Int)
id: number id: number
@Field(() => Number) @Field(() => Float)
amount: number amount: number
@Field(() => String) @Field(() => String)
@ -40,15 +42,15 @@ export class GdtEntry {
@Field(() => GdtEntryType) @Field(() => GdtEntryType)
gdtEntryType: GdtEntryType gdtEntryType: GdtEntryType
@Field(() => Number) @Field(() => Float)
factor: number factor: number
@Field(() => Number) @Field(() => Float)
amount2: number amount2: number
@Field(() => Number) @Field(() => Float)
factor2: number factor2: number
@Field(() => Number) @Field(() => Float)
gdt: number gdt: number
} }

View File

@ -1,7 +1,10 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* 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 { GdtEntry } from './GdtEntry'
import { ObjectType, Field } from 'type-graphql' import { ObjectType, Field, Int, Float } from 'type-graphql'
@ObjectType() @ObjectType()
export class GdtEntryList { export class GdtEntryList {
@ -16,15 +19,15 @@ export class GdtEntryList {
@Field(() => String) @Field(() => String)
state: string state: string
@Field(() => Number) @Field(() => Int)
count: number count: number
@Field(() => [GdtEntry], { nullable: true }) @Field(() => [GdtEntry], { nullable: true })
gdtEntries?: GdtEntry[] gdtEntries: GdtEntry[] | null
@Field(() => Number) @Field(() => Float)
gdtSum: number gdtSum: number
@Field(() => Number) @Field(() => Float)
timeUsed: number timeUsed: number
} }

View File

@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { ObjectType, Field } from 'type-graphql' import { ObjectType, Field } from 'type-graphql'

View File

@ -1,4 +1,4 @@
import { ObjectType, Field } from 'type-graphql' import { ObjectType, Field, Int } from 'type-graphql'
import { Decay } from './Decay' 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'
@ -41,19 +41,19 @@ export class Transaction {
this.memo = transaction.memo this.memo = transaction.memo
this.creationDate = transaction.creationDate this.creationDate = transaction.creationDate
this.linkedUser = linkedUser this.linkedUser = linkedUser
this.linkedTransactionId = transaction.linkedTransactionId this.linkedTransactionId = transaction.linkedTransactionId || null
this.linkId = transaction.contribution this.linkId = transaction.contribution
? transaction.contribution.contributionLinkId ? transaction.contribution.contributionLinkId
: transaction.transactionLinkId : transaction.transactionLinkId || null
} }
@Field(() => Number) @Field(() => Int)
id: number id: number
@Field(() => User) @Field(() => User)
user: User user: User
@Field(() => Number, { nullable: true }) @Field(() => Int, { nullable: true })
previous: number | null previous: number | null
@Field(() => TransactionTypeId) @Field(() => TransactionTypeId)
@ -80,10 +80,10 @@ export class Transaction {
@Field(() => User, { nullable: true }) @Field(() => User, { nullable: true })
linkedUser: User | null linkedUser: User | null
@Field(() => Number, { nullable: true }) @Field(() => Int, { nullable: true })
linkedTransactionId?: number | null linkedTransactionId: number | null
// Links to the TransactionLink/ContributionLink when transaction was created by a link // Links to the TransactionLink/ContributionLink when transaction was created by a link
@Field(() => Number, { nullable: true }) @Field(() => Int, { nullable: true })
linkId?: number | null linkId: number | null
} }

View File

@ -21,7 +21,7 @@ export class TransactionLink {
this.link = CONFIG.COMMUNITY_REDEEM_URL.replace(/{code}/g, this.code) this.link = CONFIG.COMMUNITY_REDEEM_URL.replace(/{code}/g, this.code)
} }
@Field(() => Number) @Field(() => Int)
id: number id: number
@Field(() => User) @Field(() => User)

View File

@ -24,12 +24,12 @@ export class UnconfirmedContribution {
firstName: string firstName: string
@Field(() => Int) @Field(() => Int)
id?: number id: number
@Field(() => String) @Field(() => String)
lastName: string lastName: string
@Field(() => Number) @Field(() => Int)
userId: number userId: number
@Field(() => String) @Field(() => String)
@ -44,7 +44,7 @@ export class UnconfirmedContribution {
@Field(() => Decimal) @Field(() => Decimal)
amount: Decimal amount: Decimal
@Field(() => Number, { nullable: true }) @Field(() => Int, { nullable: true })
moderator: number | null moderator: number | null
@Field(() => [Decimal]) @Field(() => [Decimal])
@ -53,6 +53,6 @@ export class UnconfirmedContribution {
@Field(() => String) @Field(() => String)
state: string state: string
@Field(() => Number) @Field(() => Int)
messageCount: number messageCount: number
} }

View File

@ -1,4 +1,4 @@
import { ObjectType, Field } from 'type-graphql' import { ObjectType, Field, Int } from 'type-graphql'
import { KlickTipp } from './KlickTipp' import { KlickTipp } from './KlickTipp'
import { User as dbUser } from '@entity/User' import { User as dbUser } from '@entity/User'
import { UserContact } from './UserContact' import { UserContact } from './UserContact'
@ -28,21 +28,21 @@ export class User {
this.hideAmountGDT = user.hideAmountGDT this.hideAmountGDT = user.hideAmountGDT
} }
@Field(() => Number) @Field(() => Int)
id: number id: number
@Field(() => String) @Field(() => String)
gradidoID: string gradidoID: string
@Field(() => String, { nullable: true }) @Field(() => String, { nullable: true })
alias?: string alias: string | null
@Field(() => Number, { nullable: true }) @Field(() => Int, { nullable: true })
emailId: number | null emailId: number | null
// TODO privacy issue here // TODO privacy issue here
@Field(() => String, { nullable: true }) @Field(() => String, { nullable: true })
email: string email: string | null
@Field(() => UserContact) @Field(() => UserContact)
emailContact: UserContact emailContact: UserContact
@ -72,7 +72,7 @@ export class User {
hideAmountGDT: boolean hideAmountGDT: boolean
// This is not the users publisherId, but the one of the users who recommend him // This is not the users publisherId, but the one of the users who recommend him
@Field(() => Number, { nullable: true }) @Field(() => Int, { nullable: true })
publisherId: number | null publisherId: number | null
@Field(() => Date, { nullable: true }) @Field(() => Date, { nullable: true })

View File

@ -17,7 +17,7 @@ export class UserAdmin {
this.isAdmin = user.isAdmin this.isAdmin = user.isAdmin
} }
@Field(() => Number) @Field(() => Int)
userId: number userId: number
@Field(() => String) @Field(() => String)
@ -39,10 +39,10 @@ export class UserAdmin {
hasElopage: boolean hasElopage: boolean
@Field(() => Date, { nullable: true }) @Field(() => Date, { nullable: true })
deletedAt?: Date | null deletedAt: Date | null
@Field(() => String, { nullable: true }) @Field(() => String, { nullable: true })
emailConfirmationSend?: string emailConfirmationSend: string | null
@Field(() => Date, { nullable: true }) @Field(() => Date, { nullable: true })
isAdmin: Date | null isAdmin: Date | null

View File

@ -1,4 +1,4 @@
import { ObjectType, Field } from 'type-graphql' import { ObjectType, Field, Int } from 'type-graphql'
import { UserContact as dbUserContact } from '@entity/UserContact' import { UserContact as dbUserContact } from '@entity/UserContact'
@ObjectType() @ObjectType()
@ -18,13 +18,13 @@ export class UserContact {
this.deletedAt = userContact.deletedAt this.deletedAt = userContact.deletedAt
} }
@Field(() => Number) @Field(() => Int)
id: number id: number
@Field(() => String) @Field(() => String)
type: string type: string
@Field(() => Number) @Field(() => Int)
userId: number userId: number
@Field(() => String) @Field(() => String)
@ -33,10 +33,10 @@ export class UserContact {
// @Field(() => BigInt, { nullable: true }) // @Field(() => BigInt, { nullable: true })
// emailVerificationCode: BigInt | null // emailVerificationCode: BigInt | null
@Field(() => Number, { nullable: true }) @Field(() => Int, { nullable: true })
emailOptInTypeId: number | null emailOptInTypeId: number | null
@Field(() => Number, { nullable: true }) @Field(() => Int, { nullable: true })
emailResendCount: number | null emailResendCount: number | null
@Field(() => Boolean) @Field(() => Boolean)

View File

@ -1,3 +1,4 @@
/* 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'

View File

@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/unbound-method */
/* 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 */

View File

@ -9,7 +9,7 @@ import CONFIG from '@/config'
export class CommunityResolver { export class CommunityResolver {
@Authorized([RIGHTS.GET_COMMUNITY_INFO]) @Authorized([RIGHTS.GET_COMMUNITY_INFO])
@Query(() => Community) @Query(() => Community)
async getCommunityInfo(): Promise<Community> { getCommunityInfo(): Community {
return new Community({ return new Community({
name: CONFIG.COMMUNITY_NAME, name: CONFIG.COMMUNITY_NAME,
description: CONFIG.COMMUNITY_DESCRIPTION, description: CONFIG.COMMUNITY_DESCRIPTION,
@ -20,7 +20,7 @@ export class CommunityResolver {
@Authorized([RIGHTS.COMMUNITIES]) @Authorized([RIGHTS.COMMUNITIES])
@Query(() => [Community]) @Query(() => [Community])
async communities(): Promise<Community[]> { communities(): Community[] {
if (CONFIG.PRODUCTION) if (CONFIG.PRODUCTION)
return [ return [
new Community({ new Community({

View File

@ -1,3 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* 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'

View File

@ -35,7 +35,7 @@ export class ContributionLinkResolver {
cycle, cycle,
validFrom, validFrom,
validTo, validTo,
maxAmountPerMonth, maxAmountPerMonth = null,
maxPerCycle, maxPerCycle,
}: ContributionLinkArgs, }: ContributionLinkArgs,
): Promise<ContributionLink> { ): Promise<ContributionLink> {
@ -114,7 +114,7 @@ export class ContributionLinkResolver {
cycle, cycle,
validFrom, validFrom,
validTo, validTo,
maxAmountPerMonth, maxAmountPerMonth = null,
maxPerCycle, maxPerCycle,
}: ContributionLinkArgs, }: ContributionLinkArgs,
@Arg('id', () => Int) id: number, @Arg('id', () => Int) id: number,

View File

@ -1,3 +1,8 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* 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 */
@ -181,7 +186,7 @@ describe('ContributionMessageResolver', () => {
) )
}) })
it('calls sendAddedContributionMessageEmail', async () => { it('calls sendAddedContributionMessageEmail', () => {
expect(sendAddedContributionMessageEmail).toBeCalledWith({ expect(sendAddedContributionMessageEmail).toBeCalledWith({
firstName: 'Bibi', firstName: 'Bibi',
lastName: 'Bloxberg', lastName: 'Bloxberg',

View File

@ -1,4 +1,5 @@
import { Arg, Args, Authorized, Ctx, Mutation, Query, Resolver } from 'type-graphql' /* eslint-disable @typescript-eslint/restrict-template-expressions */
import { Arg, Args, Authorized, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql'
import { getConnection } from '@dbTools/typeorm' import { getConnection } from '@dbTools/typeorm'
import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage'
@ -68,7 +69,7 @@ export class ContributionMessageResolver {
@Authorized([RIGHTS.LIST_ALL_CONTRIBUTION_MESSAGES]) @Authorized([RIGHTS.LIST_ALL_CONTRIBUTION_MESSAGES])
@Query(() => ContributionMessageListResult) @Query(() => ContributionMessageListResult)
async listContributionMessages( async listContributionMessages(
@Arg('contributionId') contributionId: number, @Arg('contributionId', () => Int) contributionId: number,
@Args() @Args()
{ currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated, { currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated,
): Promise<ContributionMessageListResult> { ): Promise<ContributionMessageListResult> {

View File

@ -1,3 +1,8 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* 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 */
@ -176,7 +181,7 @@ describe('ContributionResolver', () => {
}) })
}) })
afterAll(async () => { afterAll(() => {
resetToken() resetToken()
}) })
@ -265,7 +270,7 @@ describe('ContributionResolver', () => {
}) })
describe('valid input', () => { describe('valid input', () => {
it('creates contribution', async () => { it('creates contribution', () => {
expect(pendingContribution.data.createContribution).toMatchObject({ expect(pendingContribution.data.createContribution).toMatchObject({
id: expect.any(Number), id: expect.any(Number),
amount: '100', amount: '100',
@ -312,7 +317,7 @@ describe('ContributionResolver', () => {
}) })
}) })
afterAll(async () => { afterAll(() => {
resetToken() resetToken()
}) })
@ -453,7 +458,7 @@ describe('ContributionResolver', () => {
id: pendingContribution.data.createContribution.id, id: pendingContribution.data.createContribution.id,
}) })
contribution.contributionStatus = ContributionStatus.DELETED contribution.contributionStatus = ContributionStatus.DELETED
contribution.save() await contribution.save()
await mutate({ await mutate({
mutation: login, mutation: login,
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
@ -465,7 +470,7 @@ describe('ContributionResolver', () => {
id: pendingContribution.data.createContribution.id, id: pendingContribution.data.createContribution.id,
}) })
contribution.contributionStatus = ContributionStatus.PENDING contribution.contributionStatus = ContributionStatus.PENDING
contribution.save() await contribution.save()
}) })
it('throws an error', async () => { it('throws an error', async () => {
@ -638,7 +643,7 @@ describe('ContributionResolver', () => {
}) })
}) })
afterAll(async () => { afterAll(() => {
resetToken() resetToken()
}) })
@ -822,7 +827,7 @@ describe('ContributionResolver', () => {
) )
}) })
it('calls sendContributionDeniedEmail', async () => { it('calls sendContributionDeniedEmail', () => {
expect(sendContributionDeniedEmail).toBeCalledWith({ expect(sendContributionDeniedEmail).toBeCalledWith({
firstName: 'Bibi', firstName: 'Bibi',
lastName: 'Bloxberg', lastName: 'Bloxberg',
@ -858,7 +863,7 @@ describe('ContributionResolver', () => {
}) })
}) })
afterAll(async () => { afterAll(() => {
resetToken() resetToken()
}) })
@ -998,7 +1003,6 @@ describe('ContributionResolver', () => {
currentPage: 1, currentPage: 1,
pageSize: 25, pageSize: 25,
order: 'DESC', order: 'DESC',
filterConfirmed: false,
}, },
}) })
expect(errorObjects).toEqual([new GraphQLError('401 Unauthorized')]) expect(errorObjects).toEqual([new GraphQLError('401 Unauthorized')])
@ -1013,11 +1017,11 @@ describe('ContributionResolver', () => {
}) })
}) })
afterAll(async () => { afterAll(() => {
resetToken() resetToken()
}) })
describe('filter confirmed is false', () => { describe('no status filter', () => {
it('returns creations', async () => { it('returns creations', async () => {
const { const {
data: { listContributions: contributionListResult }, data: { listContributions: contributionListResult },
@ -1069,7 +1073,7 @@ describe('ContributionResolver', () => {
}) })
}) })
describe('filter confirmed is true', () => { describe('with status filter [PENDING, IN_PROGRESS, DENIED, DELETED]', () => {
it('returns only unconfirmed creations', async () => { it('returns only unconfirmed creations', async () => {
const { const {
data: { listContributions: contributionListResult }, data: { listContributions: contributionListResult },
@ -1079,7 +1083,7 @@ describe('ContributionResolver', () => {
currentPage: 1, currentPage: 1,
pageSize: 25, pageSize: 25,
order: 'DESC', order: 'DESC',
filterConfirmed: true, statusFilter: ['PENDING', 'IN_PROGRESS', 'DENIED', 'DELETED'],
}, },
}) })
expect(contributionListResult).toMatchObject({ expect(contributionListResult).toMatchObject({
@ -1144,7 +1148,7 @@ describe('ContributionResolver', () => {
}) })
}) })
afterAll(async () => { afterAll(() => {
resetToken() resetToken()
}) })
@ -1724,7 +1728,7 @@ describe('ContributionResolver', () => {
}) })
}) })
afterAll(async () => { afterAll(() => {
resetToken() resetToken()
}) })
@ -1802,7 +1806,7 @@ describe('ContributionResolver', () => {
}) })
}) })
afterAll(async () => { afterAll(() => {
resetToken() resetToken()
}) })
@ -1917,7 +1921,7 @@ describe('ContributionResolver', () => {
}) })
describe('valid user to create for', () => { describe('valid user to create for', () => {
beforeAll(async () => { beforeAll(() => {
variables.email = 'bibi@bloxberg.de' variables.email = 'bibi@bloxberg.de'
variables.creationDate = 'invalid-date' variables.creationDate = 'invalid-date'
}) })
@ -2023,7 +2027,7 @@ describe('ContributionResolver', () => {
).resolves.toEqual( ).resolves.toEqual(
expect.objectContaining({ expect.objectContaining({
data: { data: {
adminCreateContribution: [1000, 1000, 590], adminCreateContribution: ['1000', '1000', '590'],
}, },
}), }),
) )
@ -2395,7 +2399,7 @@ describe('ContributionResolver', () => {
) )
}) })
it('calls sendContributionDeletedEmail', async () => { it('calls sendContributionDeletedEmail', () => {
expect(sendContributionDeletedEmail).toBeCalledWith({ expect(sendContributionDeletedEmail).toBeCalledWith({
firstName: 'Peter', firstName: 'Peter',
lastName: 'Lustig', lastName: 'Lustig',
@ -2560,7 +2564,7 @@ describe('ContributionResolver', () => {
expect(transaction[0].typeId).toEqual(1) expect(transaction[0].typeId).toEqual(1)
}) })
it('calls sendContributionConfirmedEmail', async () => { it('calls sendContributionConfirmedEmail', () => {
expect(sendContributionConfirmedEmail).toBeCalledWith({ expect(sendContributionConfirmedEmail).toBeCalledWith({
firstName: 'Bibi', firstName: 'Bibi',
lastName: 'Bloxberg', lastName: 'Bloxberg',
@ -2754,15 +2758,6 @@ describe('ContributionResolver', () => {
messagesCount: 0, messagesCount: 0,
state: 'CONFIRMED', state: 'CONFIRMED',
}), }),
expect.objectContaining({
amount: expect.decimalEqual(100),
firstName: 'Bob',
id: expect.any(Number),
lastName: 'der Baumeister',
memo: 'Confirmed Contribution',
messagesCount: 0,
state: 'CONFIRMED',
}),
expect.objectContaining({ expect.objectContaining({
amount: expect.decimalEqual(400), amount: expect.decimalEqual(400),
firstName: 'Peter', firstName: 'Peter',
@ -2772,6 +2767,15 @@ describe('ContributionResolver', () => {
messagesCount: 0, messagesCount: 0,
state: 'PENDING', state: 'PENDING',
}), }),
expect.objectContaining({
amount: expect.decimalEqual(100),
firstName: 'Bob',
id: expect.any(Number),
lastName: 'der Baumeister',
memo: 'Confirmed Contribution',
messagesCount: 0,
state: 'CONFIRMED',
}),
expect.objectContaining({ expect.objectContaining({
amount: expect.decimalEqual(100), amount: expect.decimalEqual(100),
firstName: 'Peter', firstName: 'Peter',
@ -2790,15 +2794,6 @@ describe('ContributionResolver', () => {
messagesCount: 0, messagesCount: 0,
state: 'PENDING', state: 'PENDING',
}), }),
expect.objectContaining({
amount: expect.decimalEqual(10),
firstName: 'Bibi',
id: expect.any(Number),
lastName: 'Bloxberg',
memo: 'Test PENDING contribution update',
messagesCount: 0,
state: 'PENDING',
}),
expect.objectContaining({ expect.objectContaining({
amount: expect.decimalEqual(200), amount: expect.decimalEqual(200),
firstName: 'Peter', firstName: 'Peter',
@ -2808,15 +2803,6 @@ describe('ContributionResolver', () => {
messagesCount: 0, messagesCount: 0,
state: 'DELETED', state: 'DELETED',
}), }),
expect.objectContaining({
amount: expect.decimalEqual(166),
firstName: 'Räuber',
id: expect.any(Number),
lastName: 'Hotzenplotz',
memo: 'Whatever contribution',
messagesCount: 0,
state: 'DELETED',
}),
expect.objectContaining({ expect.objectContaining({
amount: expect.decimalEqual(166), amount: expect.decimalEqual(166),
firstName: 'Räuber', firstName: 'Räuber',
@ -2826,6 +2812,15 @@ describe('ContributionResolver', () => {
messagesCount: 0, messagesCount: 0,
state: 'DENIED', state: 'DENIED',
}), }),
expect.objectContaining({
amount: expect.decimalEqual(166),
firstName: 'Räuber',
id: expect.any(Number),
lastName: 'Hotzenplotz',
memo: 'Whatever contribution',
messagesCount: 0,
state: 'DELETED',
}),
expect.objectContaining({ expect.objectContaining({
amount: expect.decimalEqual(166), amount: expect.decimalEqual(166),
firstName: 'Räuber', firstName: 'Räuber',
@ -2840,18 +2835,9 @@ describe('ContributionResolver', () => {
firstName: 'Bibi', firstName: 'Bibi',
id: expect.any(Number), id: expect.any(Number),
lastName: 'Bloxberg', lastName: 'Bloxberg',
memo: 'Test IN_PROGRESS contribution', memo: 'Test contribution to delete',
messagesCount: 0, messagesCount: 0,
state: 'IN_PROGRESS', state: 'DELETED',
}),
expect.objectContaining({
amount: expect.decimalEqual(100),
firstName: 'Bibi',
id: expect.any(Number),
lastName: 'Bloxberg',
memo: 'Test contribution to confirm',
messagesCount: 0,
state: 'CONFIRMED',
}), }),
expect.objectContaining({ expect.objectContaining({
amount: expect.decimalEqual(100), amount: expect.decimalEqual(100),
@ -2867,9 +2853,27 @@ describe('ContributionResolver', () => {
firstName: 'Bibi', firstName: 'Bibi',
id: expect.any(Number), id: expect.any(Number),
lastName: 'Bloxberg', lastName: 'Bloxberg',
memo: 'Test contribution to delete', memo: 'Test contribution to confirm',
messagesCount: 0, messagesCount: 0,
state: 'DELETED', state: 'CONFIRMED',
}),
expect.objectContaining({
amount: expect.decimalEqual(100),
firstName: 'Bibi',
id: expect.any(Number),
lastName: 'Bloxberg',
memo: 'Test IN_PROGRESS contribution',
messagesCount: 1,
state: 'IN_PROGRESS',
}),
expect.objectContaining({
amount: expect.decimalEqual(10),
firstName: 'Bibi',
id: expect.any(Number),
lastName: 'Bloxberg',
memo: 'Test PENDING contribution update',
messagesCount: 1,
state: 'PENDING',
}), }),
expect.objectContaining({ expect.objectContaining({
amount: expect.decimalEqual(1000), amount: expect.decimalEqual(1000),

View File

@ -1,6 +1,7 @@
/* 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 { FindOperator, IsNull, getConnection } from '@dbTools/typeorm' import { IsNull, getConnection } from '@dbTools/typeorm'
import { Contribution as DbContribution } from '@entity/Contribution' import { Contribution as DbContribution } from '@entity/Contribution'
import { ContributionMessage } from '@entity/ContributionMessage' import { ContributionMessage } from '@entity/ContributionMessage'
@ -27,11 +28,11 @@ 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 { import {
getCreationDates,
getUserCreation, getUserCreation,
validateContribution, validateContribution,
updateCreations, updateCreations,
isValidDateString, isValidDateString,
getOpenCreations,
} from './util/creations' } from './util/creations'
import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const' import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const'
import { import {
@ -127,35 +128,26 @@ export class ContributionResolver {
@Authorized([RIGHTS.LIST_CONTRIBUTIONS]) @Authorized([RIGHTS.LIST_CONTRIBUTIONS])
@Query(() => ContributionListResult) @Query(() => ContributionListResult)
async listContributions( async listContributions(
@Ctx() context: Context,
@Args() @Args()
{ currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated, { currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated,
@Arg('filterConfirmed', () => Boolean) @Arg('statusFilter', () => [ContributionStatus], { nullable: true })
filterConfirmed: boolean | null, statusFilter?: ContributionStatus[] | null,
@Ctx() context: Context,
): Promise<ContributionListResult> { ): Promise<ContributionListResult> {
const user = getUser(context) const user = getUser(context)
const where: {
userId: number
confirmedBy?: FindOperator<number> | null
} = { userId: user.id }
if (filterConfirmed) where.confirmedBy = IsNull()
const [contributions, count] = await getConnection()
.createQueryBuilder()
.select('c')
.from(DbContribution, 'c')
.leftJoinAndSelect('c.messages', 'm')
.where(where)
.withDeleted()
.orderBy('c.createdAt', order)
.limit(pageSize)
.offset((currentPage - 1) * pageSize)
.getManyAndCount()
const [dbContributions, count] = await findContributions(
order,
currentPage,
pageSize,
true,
['messages'],
user.id,
statusFilter,
)
return new ContributionListResult( return new ContributionListResult(
count, count,
contributions.map((contribution) => new Contribution(contribution, user)), dbContributions.map((contribution) => new Contribution(contribution, user)),
) )
} }
@ -165,13 +157,15 @@ export class ContributionResolver {
@Args() @Args()
{ currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated, { currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated,
@Arg('statusFilter', () => [ContributionStatus], { nullable: true }) @Arg('statusFilter', () => [ContributionStatus], { nullable: true })
statusFilter?: ContributionStatus[], statusFilter?: ContributionStatus[] | null,
): Promise<ContributionListResult> { ): Promise<ContributionListResult> {
const [dbContributions, count] = await findContributions( const [dbContributions, count] = await findContributions(
order, order,
currentPage, currentPage,
pageSize, pageSize,
false, false,
['user'],
undefined,
statusFilter, statusFilter,
) )
@ -246,14 +240,14 @@ export class ContributionResolver {
contributionMessage.isModerator = false contributionMessage.isModerator = false
contributionMessage.userId = user.id contributionMessage.userId = user.id
contributionMessage.type = ContributionMessageType.HISTORY contributionMessage.type = ContributionMessageType.HISTORY
ContributionMessage.save(contributionMessage) await ContributionMessage.save(contributionMessage)
contributionToUpdate.amount = amount contributionToUpdate.amount = amount
contributionToUpdate.memo = memo contributionToUpdate.memo = memo
contributionToUpdate.contributionDate = new Date(creationDate) contributionToUpdate.contributionDate = new Date(creationDate)
contributionToUpdate.contributionStatus = ContributionStatus.PENDING contributionToUpdate.contributionStatus = ContributionStatus.PENDING
contributionToUpdate.updatedAt = new Date() contributionToUpdate.updatedAt = new Date()
DbContribution.save(contributionToUpdate) await DbContribution.save(contributionToUpdate)
await EVENT_CONTRIBUTION_UPDATE(user, contributionToUpdate, amount) await EVENT_CONTRIBUTION_UPDATE(user, contributionToUpdate, amount)
@ -261,7 +255,7 @@ export class ContributionResolver {
} }
@Authorized([RIGHTS.ADMIN_CREATE_CONTRIBUTION]) @Authorized([RIGHTS.ADMIN_CREATE_CONTRIBUTION])
@Mutation(() => [Number]) @Mutation(() => [Decimal])
async adminCreateContribution( async adminCreateContribution(
@Args() { email, amount, memo, creationDate }: AdminCreateContributionArgs, @Args() { email, amount, memo, creationDate }: AdminCreateContributionArgs,
@Ctx() context: Context, @Ctx() context: Context,
@ -396,13 +390,15 @@ export class ContributionResolver {
@Args() @Args()
{ currentPage = 1, pageSize = 3, order = Order.DESC }: Paginated, { currentPage = 1, pageSize = 3, order = Order.DESC }: Paginated,
@Arg('statusFilter', () => [ContributionStatus], { nullable: true }) @Arg('statusFilter', () => [ContributionStatus], { nullable: true })
statusFilter?: ContributionStatus[], statusFilter?: ContributionStatus[] | null,
): Promise<ContributionListResult> { ): Promise<ContributionListResult> {
const [dbContributions, count] = await findContributions( const [dbContributions, count] = await findContributions(
order, order,
currentPage, currentPage,
pageSize, pageSize,
true, true,
['user', 'messages'],
undefined,
statusFilter, statusFilter,
) )
@ -448,7 +444,7 @@ export class ContributionResolver {
contribution.amount, contribution.amount,
) )
sendContributionDeletedEmail({ void sendContributionDeletedEmail({
firstName: user.firstName, firstName: user.firstName,
lastName: user.lastName, lastName: user.lastName,
email: user.emailContact.email, email: user.emailContact.email,
@ -542,7 +538,7 @@ export class ContributionResolver {
await queryRunner.commitTransaction() await queryRunner.commitTransaction()
logger.info('creation commited successfuly.') logger.info('creation commited successfuly.')
sendContributionConfirmedEmail({ void sendContributionConfirmedEmail({
firstName: user.firstName, firstName: user.firstName,
lastName: user.lastName, lastName: user.lastName,
email: user.emailContact.email, email: user.emailContact.email,
@ -595,21 +591,17 @@ export class ContributionResolver {
@Authorized([RIGHTS.OPEN_CREATIONS]) @Authorized([RIGHTS.OPEN_CREATIONS])
@Query(() => [OpenCreation]) @Query(() => [OpenCreation])
async openCreations( async openCreations(@Ctx() context: Context): Promise<OpenCreation[]> {
@Arg('userId', () => Int, { nullable: true }) userId: number | null, return getOpenCreations(getUser(context).id, getClientTimezoneOffset(context))
}
@Authorized([RIGHTS.ADMIN_OPEN_CREATIONS])
@Query(() => [OpenCreation])
async adminOpenCreations(
@Arg('userId', () => Int) userId: number,
@Ctx() context: Context, @Ctx() context: Context,
): Promise<OpenCreation[]> { ): Promise<OpenCreation[]> {
const id = userId || getUser(context).id return getOpenCreations(userId, getClientTimezoneOffset(context))
const clientTimezoneOffset = getClientTimezoneOffset(context)
const creationDates = getCreationDates(clientTimezoneOffset)
const creations = await getUserCreation(id, clientTimezoneOffset)
return creationDates.map((date, index) => {
return {
month: date.getMonth(),
year: date.getFullYear(),
amount: creations[index],
}
})
} }
@Authorized([RIGHTS.DENY_CONTRIBUTION]) @Authorized([RIGHTS.DENY_CONTRIBUTION])
@ -656,7 +648,7 @@ export class ContributionResolver {
contributionToUpdate.amount, contributionToUpdate.amount,
) )
sendContributionDeniedEmail({ void sendContributionDeniedEmail({
firstName: user.firstName, firstName: user.firstName,
lastName: user.lastName, lastName: user.lastName,
email: user.emailContact.email, email: user.emailContact.email,

View File

@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* 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 */

View File

@ -1,4 +1,7 @@
import { Resolver, Query, Args, Ctx, Authorized, Arg } from 'type-graphql' /* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-return */
import { Resolver, Query, Args, Ctx, Authorized, Arg, Int, Float } from 'type-graphql'
import { GdtEntryList } from '@model/GdtEntryList' import { GdtEntryList } from '@model/GdtEntryList'
import { Order } from '@enum/Order' import { Order } from '@enum/Order'
@ -23,6 +26,7 @@ export class GdtResolver {
try { try {
const resultGDT = await apiGet( const resultGDT = await apiGet(
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`${CONFIG.GDT_API_URL}/GdtEntries/listPerEmailApi/${userEntity.emailContact.email}/${currentPage}/${pageSize}/${order}`, `${CONFIG.GDT_API_URL}/GdtEntries/listPerEmailApi/${userEntity.emailContact.email}/${currentPage}/${pageSize}/${order}`,
) )
if (!resultGDT.success) { if (!resultGDT.success) {
@ -35,7 +39,7 @@ export class GdtResolver {
} }
@Authorized([RIGHTS.GDT_BALANCE]) @Authorized([RIGHTS.GDT_BALANCE])
@Query(() => Number) @Query(() => Float, { nullable: true })
async gdtBalance(@Ctx() context: Context): Promise<number | null> { async gdtBalance(@Ctx() context: Context): Promise<number | null> {
const user = getUser(context) const user = getUser(context)
try { try {
@ -54,9 +58,9 @@ export class GdtResolver {
} }
@Authorized([RIGHTS.EXIST_PID]) @Authorized([RIGHTS.EXIST_PID])
@Query(() => Number) @Query(() => Int)
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
async existPid(@Arg('pid') pid: number): Promise<number> { async existPid(@Arg('pid', () => Int) pid: number): Promise<number> {
// load user // load user
const resultPID = await apiGet(`${CONFIG.GDT_API_URL}/publishers/checkPidApi/${pid}`) const resultPID = await apiGet(`${CONFIG.GDT_API_URL}/publishers/checkPidApi/${pid}`)
if (!resultPID.success) { if (!resultPID.success) {

View File

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
import { Resolver, Query, Authorized, Arg, Mutation, Args } from 'type-graphql' import { Resolver, Query, Authorized, Arg, Mutation, Args } from 'type-graphql'
import SubscribeNewsletterArgs from '@arg/SubscribeNewsletterArgs' import SubscribeNewsletterArgs from '@arg/SubscribeNewsletterArgs'

View File

@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* 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'
@ -15,7 +17,7 @@ import { calculateDecay } from '@/util/decay'
export class StatisticsResolver { export class StatisticsResolver {
@Authorized([RIGHTS.COMMUNITY_STATISTICS]) @Authorized([RIGHTS.COMMUNITY_STATISTICS])
@Query(() => CommunityStatistics) @Query(() => CommunityStatistics)
async communityStatistics(): Promise<CommunityStatistics> { communityStatistics(): CommunityStatistics {
return new CommunityStatistics() return new CommunityStatistics()
} }

View File

@ -1,3 +1,8 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/unbound-method */
/* 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 */
@ -17,10 +22,12 @@ import {
createContribution, createContribution,
updateContribution, updateContribution,
createTransactionLink, createTransactionLink,
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 { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
import { User } from '@entity/User' 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 Decimal from 'decimal.js-light'
import { GraphQLError } from 'graphql' import { GraphQLError } from 'graphql'
@ -137,6 +144,8 @@ describe('TransactionLinkResolver', () => {
resetToken() resetToken()
}) })
let contributionId: number
describe('unauthenticated', () => { describe('unauthenticated', () => {
it('throws an error', async () => { it('throws an error', async () => {
jest.clearAllMocks() jest.clearAllMocks()
@ -210,7 +219,7 @@ describe('TransactionLinkResolver', () => {
mutate({ mutate({
mutation: redeemTransactionLink, mutation: redeemTransactionLink,
variables: { variables: {
code: 'CL-' + contributionLink.code, code: `CL-${contributionLink.code}`,
}, },
}), }),
).resolves.toMatchObject({ ).resolves.toMatchObject({
@ -249,7 +258,7 @@ describe('TransactionLinkResolver', () => {
mutate({ mutate({
mutation: redeemTransactionLink, mutation: redeemTransactionLink,
variables: { variables: {
code: 'CL-' + contributionLink.code, code: `CL-${contributionLink.code}`,
}, },
}), }),
).resolves.toMatchObject({ ).resolves.toMatchObject({
@ -288,7 +297,7 @@ describe('TransactionLinkResolver', () => {
mutate({ mutate({
mutation: redeemTransactionLink, mutation: redeemTransactionLink,
variables: { variables: {
code: 'CL-' + contributionLink.code, code: `CL-${contributionLink.code}`,
}, },
}), }),
).resolves.toMatchObject({ ).resolves.toMatchObject({
@ -306,7 +315,6 @@ describe('TransactionLinkResolver', () => {
}) })
}) })
// TODO: have this test separated into a transactionLink and a contributionLink part
describe('redeem daily Contribution Link', () => { describe('redeem daily Contribution Link', () => {
const now = new Date() const now = new Date()
let contributionLink: DbContributionLink | undefined let contributionLink: DbContributionLink | undefined
@ -332,6 +340,10 @@ describe('TransactionLinkResolver', () => {
}) })
}) })
afterAll(async () => {
await resetEntity(Transaction)
})
it('has a daily contribution link in the database', async () => { it('has a daily contribution link in the database', async () => {
const cls = await DbContributionLink.find() const cls = await DbContributionLink.find()
expect(cls).toHaveLength(1) expect(cls).toHaveLength(1)
@ -373,6 +385,7 @@ describe('TransactionLinkResolver', () => {
}, },
}) })
contribution = result.data.createContribution contribution = result.data.createContribution
contributionId = result.data.createContribution.id
}) })
it('does not allow the user to redeem the contribution link', async () => { it('does not allow the user to redeem the contribution link', async () => {
@ -508,6 +521,92 @@ describe('TransactionLinkResolver', () => {
}) })
}) })
}) })
describe('transaction link', () => {
beforeEach(() => {
jest.clearAllMocks()
})
describe('link does not exits', () => {
beforeAll(async () => {
await mutate({
mutation: login,
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
})
})
it('throws and logs the error', async () => {
await expect(
mutate({
mutation: redeemTransactionLink,
variables: {
code: 'not-valid',
},
}),
).resolves.toMatchObject({
errors: [new GraphQLError('Transaction link not found')],
})
expect(logger.error).toBeCalledWith('Transaction link not found', 'not-valid')
})
})
describe('link exists', () => {
let myCode: string
beforeAll(async () => {
await mutate({
mutation: login,
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
})
await mutate({
mutation: confirmContribution,
variables: { id: contributionId },
})
await mutate({
mutation: login,
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
})
const {
data: {
createTransactionLink: { code },
},
} = await mutate({
mutation: createTransactionLink,
variables: {
amount: 200,
memo: 'This is a transaction link from bibi',
},
})
myCode = code
})
describe('own link', () => {
beforeAll(async () => {
await mutate({
mutation: login,
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
})
})
it('throws and logs an error', async () => {
await expect(
mutate({
mutation: redeemTransactionLink,
variables: {
code: myCode,
},
}),
).resolves.toMatchObject({
errors: [new GraphQLError('Cannot redeem own transaction link')],
})
expect(logger.error).toBeCalledWith(
'Cannot redeem own transaction link',
expect.any(Number),
)
})
})
})
})
}) })
}) })

View File

@ -285,12 +285,20 @@ export class TransactionLinkResolver {
return true return true
} else { } else {
const now = new Date() const now = new Date()
const transactionLink = await DbTransactionLink.findOneOrFail({ code }) const transactionLink = await DbTransactionLink.findOne({ code })
const linkedUser = await DbUser.findOneOrFail( if (!transactionLink) {
throw new LogError('Transaction link not found', code)
}
const linkedUser = await DbUser.findOne(
{ id: transactionLink.userId }, { id: transactionLink.userId },
{ relations: ['emailContact'] }, { relations: ['emailContact'] },
) )
if (!linkedUser) {
throw new LogError('Linked user not found for given link', transactionLink.userId)
}
if (user.id === linkedUser.id) { if (user.id === linkedUser.id) {
throw new LogError('Cannot redeem own transaction link', user.id) throw new LogError('Cannot redeem own transaction link', user.id)
} }
@ -341,8 +349,9 @@ export class TransactionLinkResolver {
async listTransactionLinksAdmin( async listTransactionLinksAdmin(
@Args() @Args()
paginated: Paginated, paginated: Paginated,
// eslint-disable-next-line type-graphql/wrong-decorator-signature
@Arg('filters', () => TransactionLinkFilters, { nullable: true }) @Arg('filters', () => TransactionLinkFilters, { nullable: true })
filters: TransactionLinkFilters | null, filters: TransactionLinkFilters | null, // eslint-disable-line type-graphql/invalid-nullable-input-type
@Arg('userId', () => Int) @Arg('userId', () => Int)
userId: number, userId: number,
): Promise<TransactionLinkResult> { ): Promise<TransactionLinkResult> {

View File

@ -1,3 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/unbound-method */
/* 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 */
@ -324,7 +328,7 @@ describe('send coins', () => {
).toEqual( ).toEqual(
expect.objectContaining({ expect.objectContaining({
data: { data: {
sendCoins: 'true', sendCoins: true,
}, },
}), }),
) )
@ -381,7 +385,7 @@ describe('send coins', () => {
).resolves.toEqual( ).resolves.toEqual(
expect.objectContaining({ expect.objectContaining({
data: { data: {
sendCoins: 'true', sendCoins: true,
}, },
}), }),
) )
@ -397,7 +401,7 @@ describe('send coins', () => {
).resolves.toEqual( ).resolves.toEqual(
expect.objectContaining({ expect.objectContaining({
data: { data: {
sendCoins: 'true', sendCoins: true,
}, },
}), }),
) )
@ -413,7 +417,7 @@ describe('send coins', () => {
).resolves.toEqual( ).resolves.toEqual(
expect.objectContaining({ expect.objectContaining({
data: { data: {
sendCoins: 'true', sendCoins: true,
}, },
}), }),
) )
@ -429,7 +433,7 @@ describe('send coins', () => {
).resolves.toEqual( ).resolves.toEqual(
expect.objectContaining({ expect.objectContaining({
data: { data: {
sendCoins: 'true', sendCoins: true,
}, },
}), }),
) )

View File

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable new-cap */ /* eslint-disable new-cap */
/* eslint-disable @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-non-null-assertion */
@ -305,7 +306,7 @@ export class TransactionResolver {
} }
@Authorized([RIGHTS.SEND_COINS]) @Authorized([RIGHTS.SEND_COINS])
@Mutation(() => String) @Mutation(() => Boolean)
async sendCoins( async sendCoins(
@Args() { email, amount, memo }: TransactionSendArgs, @Args() { email, amount, memo }: TransactionSendArgs,
@Ctx() context: Context, @Ctx() context: Context,

View File

@ -1,3 +1,8 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/unbound-method */
/* 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 */
@ -182,7 +187,7 @@ describe('UserResolver', () => {
{ email: 'peter@lustig.de' }, { email: 'peter@lustig.de' },
{ relations: ['user'] }, { relations: ['user'] },
) )
expect(DbEvent.find()).resolves.toContainEqual( await expect(DbEvent.find()).resolves.toContainEqual(
expect.objectContaining({ expect.objectContaining({
type: EventProtocolType.REGISTER, type: EventProtocolType.REGISTER,
affectedUserId: userConatct.user.id, affectedUserId: userConatct.user.id,
@ -212,7 +217,7 @@ describe('UserResolver', () => {
}) })
it('stores the SEND_CONFIRMATION_EMAIL event in the database', () => { it('stores the SEND_CONFIRMATION_EMAIL event in the database', () => {
expect(DbEvent.find()).resolves.toContainEqual( await expect(DbEvent.find()).resolves.toContainEqual(
expect.objectContaining({ expect.objectContaining({
type: EventProtocolType.SEND_CONFIRMATION_EMAIL, type: EventProtocolType.SEND_CONFIRMATION_EMAIL,
affectedUserId: user[0].id, affectedUserId: user[0].id,
@ -228,7 +233,7 @@ describe('UserResolver', () => {
mutation = await mutate({ mutation: createUser, variables }) mutation = await mutate({ mutation: createUser, variables })
}) })
it('logs an info', async () => { it('logs an info', () => {
expect(logger.info).toBeCalledWith('User already exists with this email=peter@lustig.de') expect(logger.info).toBeCalledWith('User already exists with this email=peter@lustig.de')
}) })
@ -241,7 +246,7 @@ describe('UserResolver', () => {
}) })
}) })
it('results with partly faked user with random "id"', async () => { it('results with partly faked user with random "id"', () => {
expect(mutation).toEqual( expect(mutation).toEqual(
expect.objectContaining({ expect.objectContaining({
data: { data: {
@ -258,7 +263,7 @@ describe('UserResolver', () => {
{ email: 'peter@lustig.de' }, { email: 'peter@lustig.de' },
{ relations: ['user'] }, { relations: ['user'] },
) )
expect(DbEvent.find()).resolves.toContainEqual( await expect(DbEvent.find()).resolves.toContainEqual(
expect.objectContaining({ expect.objectContaining({
type: EventProtocolType.SEND_ACCOUNT_MULTIREGISTRATION_EMAIL, type: EventProtocolType.SEND_ACCOUNT_MULTIREGISTRATION_EMAIL,
affectedUserId: userConatct.user.id, affectedUserId: userConatct.user.id,
@ -286,7 +291,7 @@ describe('UserResolver', () => {
}) })
describe('no publisher id', () => { describe('no publisher id', () => {
it('sets publisher id to null', async () => { it('sets publisher id to 0', async () => {
await mutate({ await mutate({
mutation: createUser, mutation: createUser,
variables: { ...variables, email: 'raeuber@hotzenplotz.de', publisherId: undefined }, variables: { ...variables, email: 'raeuber@hotzenplotz.de', publisherId: undefined },
@ -297,7 +302,7 @@ describe('UserResolver', () => {
emailContact: expect.objectContaining({ emailContact: expect.objectContaining({
email: 'raeuber@hotzenplotz.de', email: 'raeuber@hotzenplotz.de',
}), }),
publisherId: null, publisherId: 0,
}), }),
]), ]),
) )
@ -359,7 +364,7 @@ describe('UserResolver', () => {
}) })
it('stores the ACTIVATE_ACCOUNT event in the database', () => { it('stores the ACTIVATE_ACCOUNT event in the database', () => {
expect(DbEvent.find()).resolves.toContainEqual( await expect(DbEvent.find()).resolves.toContainEqual(
expect.objectContaining({ expect.objectContaining({
type: EventProtocolType.ACTIVATE_ACCOUNT, type: EventProtocolType.ACTIVATE_ACCOUNT,
affectedUserId: user[0].id, affectedUserId: user[0].id,
@ -369,7 +374,7 @@ describe('UserResolver', () => {
}) })
it('stores the REDEEM_REGISTER event in the database', () => { it('stores the REDEEM_REGISTER event in the database', () => {
expect(DbEvent.find()).resolves.toContainEqual( await expect(DbEvent.find()).resolves.toContainEqual(
expect.objectContaining({ expect.objectContaining({
type: EventProtocolType.REDEEM_REGISTER, type: EventProtocolType.REDEEM_REGISTER,
affectedUserId: result.data.createUser.id, affectedUserId: result.data.createUser.id,
@ -687,7 +692,7 @@ describe('UserResolver', () => {
{ email: 'bibi@bloxberg.de' }, { email: 'bibi@bloxberg.de' },
{ relations: ['user'] }, { relations: ['user'] },
) )
expect(DbEvent.find()).resolves.toContainEqual( await expect(DbEvent.find()).resolves.toContainEqual(
expect.objectContaining({ expect.objectContaining({
type: EventProtocolType.LOGIN, type: EventProtocolType.LOGIN,
affectedUserId: userConatct.user.id, affectedUserId: userConatct.user.id,
@ -857,7 +862,7 @@ describe('UserResolver', () => {
it('returns true', async () => { it('returns true', async () => {
await expect(mutate({ mutation: logout })).resolves.toEqual( await expect(mutate({ mutation: logout })).resolves.toEqual(
expect.objectContaining({ expect.objectContaining({
data: { logout: 'true' }, data: { logout: true },
errors: undefined, errors: undefined,
}), }),
) )
@ -936,7 +941,7 @@ describe('UserResolver', () => {
}) })
it('stores the LOGIN event in the database', () => { it('stores the LOGIN event in the database', () => {
expect(DbEvent.find()).resolves.toContainEqual( await expect(DbEvent.find()).resolves.toContainEqual(
expect.objectContaining({ expect.objectContaining({
type: EventProtocolType.LOGIN, type: EventProtocolType.LOGIN,
affectedUserId: user[0].id, affectedUserId: user[0].id,
@ -1856,7 +1861,8 @@ describe('UserResolver', () => {
{ email: 'bibi@bloxberg.de' }, { email: 'bibi@bloxberg.de' },
{ relations: ['user'] }, { relations: ['user'] },
) )
expect(DbEvent.find()).resolves.toContainEqual(
await expect(DbEvent.find()).resolves.toContainEqual(
expect.objectContaining({ expect.objectContaining({
type: EventProtocolType.ADMIN_SEND_CONFIRMATION_EMAIL, type: EventProtocolType.ADMIN_SEND_CONFIRMATION_EMAIL,
affectedUserId: userConatct.user.id, affectedUserId: userConatct.user.id,

View File

@ -1,3 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
import i18n from 'i18n' import i18n from 'i18n'
import { v4 as uuidv4 } from 'uuid' import { v4 as uuidv4 } from 'uuid'
import { import {
@ -168,11 +172,11 @@ export class UserResolver {
// Elopage Status & Stored PublisherId // Elopage Status & Stored PublisherId
user.hasElopage = await this.hasElopage({ ...context, user: dbUser }) user.hasElopage = await this.hasElopage({ ...context, user: dbUser })
logger.info('user.hasElopage=' + user.hasElopage) logger.info('user.hasElopage', user.hasElopage)
if (!user.hasElopage && publisherId) { if (!user.hasElopage && publisherId) {
user.publisherId = publisherId user.publisherId = publisherId
dbUser.publisherId = publisherId dbUser.publisherId = publisherId
DbUser.save(dbUser) await DbUser.save(dbUser)
} }
context.setHeaders.push({ context.setHeaders.push({
@ -186,8 +190,8 @@ export class UserResolver {
} }
@Authorized([RIGHTS.LOGOUT]) @Authorized([RIGHTS.LOGOUT])
@Mutation(() => String) @Mutation(() => Boolean)
async logout(): Promise<boolean> { logout(): boolean {
// TODO: Event still missing here!! // TODO: Event still missing here!!
// TODO: We dont need this anymore, but might need this in the future in oder to invalidate a valid JWT-Token. // TODO: We dont need this anymore, but might need this in the future in oder to invalidate a valid JWT-Token.
// Furthermore this hook can be useful for tracking user behaviour (did he logout or not? Warn him if he didn't on next login) // Furthermore this hook can be useful for tracking user behaviour (did he logout or not? Warn him if he didn't on next login)
@ -204,7 +208,7 @@ export class UserResolver {
@Mutation(() => User) @Mutation(() => User)
async createUser( async createUser(
@Args() @Args()
{ email, firstName, lastName, language, publisherId, redeemCode = null }: CreateUserArgs, { email, firstName, lastName, language, publisherId = null, redeemCode = null }: CreateUserArgs,
): Promise<User> { ): Promise<User> {
logger.addContext('user', 'unknown') logger.addContext('user', 'unknown')
logger.info( logger.info(
@ -241,7 +245,7 @@ export class UserResolver {
user.lastName = lastName user.lastName = lastName
user.language = language user.language = language
user.publisherId = publisherId user.publisherId = publisherId
logger.debug('partly faked user=' + user) logger.debug('partly faked user', user)
const emailSent = await sendAccountMultiRegistrationEmail({ const emailSent = await sendAccountMultiRegistrationEmail({
firstName: foundUser.firstName, // this is the real name of the email owner, but just "firstName" would be the name of the new registrant which shall not be passed to the outside firstName: foundUser.firstName, // this is the real name of the email owner, but just "firstName" would be the name of the new registrant which shall not be passed to the outside
@ -278,15 +282,15 @@ export class UserResolver {
dbUser.firstName = firstName dbUser.firstName = firstName
dbUser.lastName = lastName dbUser.lastName = lastName
dbUser.language = language dbUser.language = language
dbUser.publisherId = publisherId dbUser.publisherId = publisherId || 0
dbUser.passwordEncryptionType = PasswordEncryptionType.NO_PASSWORD dbUser.passwordEncryptionType = PasswordEncryptionType.NO_PASSWORD
logger.debug('new dbUser=' + dbUser) logger.debug('new dbUser', dbUser)
if (redeemCode) { if (redeemCode) {
if (redeemCode.match(/^CL-/)) { if (redeemCode.match(/^CL-/)) {
const contributionLink = await DbContributionLink.findOne({ const contributionLink = await DbContributionLink.findOne({
code: redeemCode.replace('CL-', ''), code: redeemCode.replace('CL-', ''),
}) })
logger.info('redeemCode found contributionLink=' + contributionLink) logger.info('redeemCode found contributionLink', contributionLink)
if (contributionLink) { if (contributionLink) {
dbUser.contributionLinkId = contributionLink.id dbUser.contributionLinkId = contributionLink.id
// TODO this is so wrong // TODO this is so wrong
@ -294,7 +298,7 @@ export class UserResolver {
} }
} else { } else {
const transactionLink = await DbTransactionLink.findOne({ code: redeemCode }) const transactionLink = await DbTransactionLink.findOne({ code: redeemCode })
logger.info('redeemCode found transactionLink=' + transactionLink) logger.info('redeemCode found transactionLink', transactionLink)
if (transactionLink) { if (transactionLink) {
dbUser.referrerId = transactionLink.userId dbUser.referrerId = transactionLink.userId
// TODO this is so wrong // TODO this is so wrong
@ -663,7 +667,7 @@ export class UserResolver {
return 'user.' + fieldName return 'user.' + fieldName
}), }),
searchText, searchText,
filters, filters || null,
currentPage, currentPage,
pageSize, pageSize,
) )

View File

@ -1,3 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* 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'
@ -79,7 +83,7 @@ describe('semaphore', () => {
maxPerCycle: 1, maxPerCycle: 1,
}, },
}) })
contributionLinkCode = 'CL-' + contributionLink.code contributionLinkCode = `CL-${contributionLink.code}`
await mutate({ await mutate({
mutation: login, mutation: login,
variables: { email: 'bob@baumeister.de', password: 'Aa12345_' }, variables: { email: 'bob@baumeister.de', password: 'Aa12345_' },
@ -187,4 +191,50 @@ describe('semaphore', () => {
await expect(confirmBibisContribution).resolves.toMatchObject({ errors: undefined }) await expect(confirmBibisContribution).resolves.toMatchObject({ errors: undefined })
await expect(confirmBobsContribution).resolves.toMatchObject({ errors: undefined }) await expect(confirmBobsContribution).resolves.toMatchObject({ errors: undefined })
}) })
describe('redeem transaction link twice', () => {
let myCode: string
beforeAll(async () => {
await mutate({
mutation: login,
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
})
const {
data: { createTransactionLink: bibisLink },
} = await mutate({
mutation: createTransactionLink,
variables: {
amount: 20,
memo: 'Bibis Link',
},
})
myCode = bibisLink.code
await mutate({
mutation: login,
variables: { email: 'bob@baumeister.de', password: 'Aa12345_' },
})
})
it('does not throw, but should', async () => {
const redeem1 = mutate({
mutation: redeemTransactionLink,
variables: {
code: myCode,
},
})
const redeem2 = mutate({
mutation: redeemTransactionLink,
variables: {
code: myCode,
},
})
await expect(redeem1).resolves.toMatchObject({
errors: undefined,
})
await expect(redeem2).resolves.toMatchObject({
errors: undefined,
})
})
})
}) })

View File

@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* 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 */

View File

@ -1,9 +1,12 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
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 { 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 '../const/const'
import { OpenCreation } from '@model/OpenCreation'
interface CreationMap { interface CreationMap {
id: number id: number
@ -100,7 +103,7 @@ const getCreationMonths = (timezoneOffset: number): number[] => {
return getCreationDates(timezoneOffset).map((date) => date.getMonth() + 1) return getCreationDates(timezoneOffset).map((date) => date.getMonth() + 1)
} }
export const getCreationDates = (timezoneOffset: number): Date[] => { const getCreationDates = (timezoneOffset: number): Date[] => {
const clientNow = new Date() const clientNow = new Date()
clientNow.setTime(clientNow.getTime() - timezoneOffset * 60 * 1000) clientNow.setTime(clientNow.getTime() - timezoneOffset * 60 * 1000)
logger.info( logger.info(
@ -152,3 +155,18 @@ export const updateCreations = (
export const isValidDateString = (dateString: string): boolean => { export const isValidDateString = (dateString: string): boolean => {
return new Date(dateString).toString() !== 'Invalid Date' return new Date(dateString).toString() !== 'Invalid Date'
} }
export const getOpenCreations = async (
userId: number,
timezoneOffset: number,
): Promise<OpenCreation[]> => {
const creations = await getUserCreation(userId, timezoneOffset)
const creationDates = getCreationDates(timezoneOffset)
return creationDates.map((date, index) => {
return {
month: date.getMonth(),
year: date.getFullYear(),
amount: creations[index],
}
})
}

View File

@ -8,18 +8,21 @@ export const findContributions = async (
currentPage: number, currentPage: number,
pageSize: number, pageSize: number,
withDeleted: boolean, withDeleted: boolean,
statusFilter?: ContributionStatus[], relations: string[],
userId?: number,
statusFilter?: ContributionStatus[] | null,
): Promise<[DbContribution[], number]> => ): Promise<[DbContribution[], number]> =>
DbContribution.findAndCount({ DbContribution.findAndCount({
where: { where: {
...(statusFilter && statusFilter.length && { contributionStatus: In(statusFilter) }), ...(statusFilter && statusFilter.length && { contributionStatus: In(statusFilter) }),
...(userId && { userId }),
}, },
withDeleted: withDeleted, withDeleted: withDeleted,
order: { order: {
createdAt: order, createdAt: order,
id: order, id: order,
}, },
relations: ['user'], relations,
skip: (currentPage - 1) * pageSize, skip: (currentPage - 1) * pageSize,
take: pageSize, take: pageSize,
}) })

View File

@ -17,7 +17,7 @@ async function main() {
console.log(`GraphIQL available at http://localhost:${CONFIG.PORT}`) console.log(`GraphIQL available at http://localhost:${CONFIG.PORT}`)
} }
}) })
startValidateCommunities(Number(CONFIG.FEDERATION_VALIDATE_COMMUNITY_TIMER)) void startValidateCommunities(Number(CONFIG.FEDERATION_VALIDATE_COMMUNITY_TIMER))
} }
main().catch((e) => { main().catch((e) => {

View File

@ -1,3 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
import { MiddlewareFn } from 'type-graphql' import { MiddlewareFn } from 'type-graphql'
import { /* klicktippSignIn, */ getKlickTippUser } from '@/apis/KlicktippController' import { /* klicktippSignIn, */ getKlickTippUser } from '@/apis/KlicktippController'
import { KlickTipp } from '@model/KlickTipp' import { KlickTipp } from '@model/KlickTipp'

View File

@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
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'

View File

@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/unbound-method */
import { ApolloServerTestClient } from 'apollo-server-testing' import { ApolloServerTestClient } from 'apollo-server-testing'
import { login, createContributionLink } from '@/seeds/graphql/mutations' import { login, createContributionLink } from '@/seeds/graphql/mutations'
import { ContributionLink } from '@model/ContributionLink' import { ContributionLink } from '@model/ContributionLink'

View File

@ -1,3 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/unbound-method */
/* 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 */

View File

@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/unbound-method */
import { ApolloServerTestClient } from 'apollo-server-testing' import { ApolloServerTestClient } from 'apollo-server-testing'
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'

View File

@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/unbound-method */
import { createUser, setPassword } from '@/seeds/graphql/mutations' import { createUser, setPassword } from '@/seeds/graphql/mutations'
import { User } from '@entity/User' import { User } from '@entity/User'
import { UserInterface } from '@/seeds/users/UserInterface' import { UserInterface } from '@/seeds/users/UserInterface'

View File

@ -89,6 +89,12 @@ export const createTransactionLink = gql`
} }
` `
export const deleteTransactionLink = gql`
mutation ($id: Int!) {
deleteTransactionLink(id: $id)
}
`
// from admin interface // from admin interface
export const adminCreateContribution = gql` export const adminCreateContribution = gql`
@ -269,7 +275,7 @@ export const denyContribution = gql`
` `
export const createContributionMessage = gql` export const createContributionMessage = gql`
mutation ($contributionId: Float!, $message: String!) { mutation ($contributionId: Int!, $message: String!) {
createContributionMessage(contributionId: $contributionId, message: $message) { createContributionMessage(contributionId: $contributionId, message: $message) {
id id
message message
@ -283,7 +289,7 @@ export const createContributionMessage = gql`
` `
export const adminCreateContributionMessage = gql` export const adminCreateContributionMessage = gql`
mutation ($contributionId: Float!, $message: String!) { mutation ($contributionId: Int!, $message: String!) {
adminCreateContributionMessage(contributionId: $contributionId, message: $message) { adminCreateContributionMessage(contributionId: $contributionId, message: $message) {
id id
message message

View File

@ -153,13 +153,13 @@ export const listContributions = gql`
$currentPage: Int = 1 $currentPage: Int = 1
$pageSize: Int = 5 $pageSize: Int = 5
$order: Order $order: Order
$filterConfirmed: Boolean = false $statusFilter: [ContributionStatus!]
) { ) {
listContributions( listContributions(
currentPage: $currentPage currentPage: $currentPage
pageSize: $pageSize pageSize: $pageSize
order: $order order: $order
filterConfirmed: $filterConfirmed statusFilter: $statusFilter
) { ) {
contributionCount contributionCount
contributionList { contributionList {
@ -301,7 +301,7 @@ export const searchAdminUsers = gql`
` `
export const listContributionMessages = gql` export const listContributionMessages = gql`
query ($contributionId: Float!, $pageSize: Int = 25, $currentPage: Int = 1, $order: Order = ASC) { query ($contributionId: Int!, $pageSize: Int = 25, $currentPage: Int = 1, $order: Order = ASC) {
listContributionMessages( listContributionMessages(
contributionId: $contributionId contributionId: $contributionId
pageSize: $pageSize pageSize: $pageSize

View File

@ -1,3 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* 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 */
@ -94,4 +98,4 @@ const run = async () => {
await con.close() await con.close()
} }
run() void run()

View File

@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/unbound-method */
import { logger } from '@test/testSetup' import { logger } from '@test/testSetup'
import LogError from './LogError' import LogError from './LogError'

View File

@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/unbound-method */
import 'reflect-metadata' import 'reflect-metadata'
import { ApolloServer } from 'apollo-server-express' import { ApolloServer } from 'apollo-server-express'
@ -71,6 +74,7 @@ const createServer = async (
app.use(localization.init) app.use(localization.init)
// Elopage Webhook // Elopage Webhook
// eslint-disable-next-line @typescript-eslint/no-misused-promises
app.post('/hook/elopage/' + CONFIG.WEBHOOK_ELOPAGE_SECRET, elopageWebhook) app.post('/hook/elopage/' + CONFIG.WEBHOOK_ELOPAGE_SECRET, elopageWebhook)
// Apollo Server // Apollo Server

View File

@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import log4js from 'log4js' import log4js from 'log4js'
import CONFIG from '@/config' import CONFIG from '@/config'

View File

@ -1,3 +1,8 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* 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 */

View File

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { Repository, EntityRepository } from '@dbTools/typeorm' import { Repository, EntityRepository } from '@dbTools/typeorm'
import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink'
import Decimal from 'decimal.js-light' import Decimal from 'decimal.js-light'

View File

@ -7,7 +7,7 @@ export class UserRepository extends Repository<DbUser> {
async findBySearchCriteriaPagedFiltered( async findBySearchCriteriaPagedFiltered(
select: string[], select: string[],
searchCriteria: string, searchCriteria: string,
filters: SearchUsersFilters, filters: SearchUsersFilters | null,
currentPage: number, currentPage: number,
pageSize: number, pageSize: number,
): Promise<[DbUser[], number]> { ): Promise<[DbUser[], number]> {

View File

@ -10,13 +10,13 @@ describe('utils/decay', () => {
// TODO: toString() was required, we could not compare two decimals // TODO: toString() was required, we could not compare two decimals
expect(decayFormula(amount, seconds).toString()).toBe('0.999999978035040489732012') expect(decayFormula(amount, seconds).toString()).toBe('0.999999978035040489732012')
}) })
it('has correct backward calculation', async () => { it('has correct backward calculation', () => {
const amount = new Decimal(1.0) const amount = new Decimal(1.0)
const seconds = -1 const seconds = -1
expect(decayFormula(amount, seconds).toString()).toBe('1.000000021964959992727444') expect(decayFormula(amount, seconds).toString()).toBe('1.000000021964959992727444')
}) })
// we get pretty close, but not exact here, skipping // we get pretty close, but not exact here, skipping
it.skip('has correct forward calculation', async () => { it.skip('has correct forward calculation', () => {
const amount = new Decimal(1.0).div( const amount = new Decimal(1.0).div(
new Decimal('0.99999997803504048973201202316767079413460520837376'), new Decimal('0.99999997803504048973201202316767079413460520837376'),
) )
@ -24,7 +24,7 @@ describe('utils/decay', () => {
expect(decayFormula(amount, seconds).toString()).toBe('1.0') expect(decayFormula(amount, seconds).toString()).toBe('1.0')
}) })
}) })
it('has base 0.99999997802044727', async () => { it('has base 0.99999997802044727', () => {
const now = new Date() const now = new Date()
now.setSeconds(1) now.setSeconds(1)
const oneSecondAgo = new Date(now.getTime()) const oneSecondAgo = new Date(now.getTime())
@ -34,7 +34,7 @@ describe('utils/decay', () => {
) )
}) })
it('returns input amount when from and to is the same', async () => { it('returns input amount when from and to is the same', () => {
const now = new Date() const now = new Date()
expect(calculateDecay(new Decimal(100.0), now, now).balance.toString()).toBe('100') expect(calculateDecay(new Decimal(100.0), now, now).balance.toString()).toBe('100')
}) })

View File

@ -26,4 +26,4 @@ export async function retrieveNotRegisteredEmails(): Promise<string[]> {
return notRegisteredUser return notRegisteredUser
} }
retrieveNotRegisteredEmails() void retrieveNotRegisteredEmails()

View File

@ -1,3 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* 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 */
/* /*

Some files were not shown because too many files have changed in this diff Show More