From 190038eaa1e39819f7fdb4221dbe7ff88745b085 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 26 Jan 2022 15:54:19 +0100 Subject: [PATCH 01/12] fix updatePendingCreation method logic, now it checks if the updated datas are allowed so that no user can get more than 1000 GDD per month. --- backend/src/graphql/resolver/AdminResolver.ts | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index 8a7e034a5..d658fce2e 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -113,25 +113,35 @@ export class AdminResolver { const user = await userRepository.findByEmail(email) const loginPendingTasksAdminRepository = getCustomRepository(LoginPendingTasksAdminRepository) - const updatedCreation = await loginPendingTasksAdminRepository.findOneOrFail({ id }) + const pendingCreationToUpdate = await loginPendingTasksAdminRepository.findOneOrFail({ id }) - if (updatedCreation.userId !== user.id) + if (pendingCreationToUpdate.userId !== user.id) { throw new Error('user of the pending creation and send user does not correspond') + } - updatedCreation.amount = BigInt(amount * 10000) - updatedCreation.memo = memo - updatedCreation.date = new Date(creationDate) - updatedCreation.moderator = moderator + const creationDateObj = new Date(creationDate) + const creations = await getUserCreations(user.id) - await loginPendingTasksAdminRepository.save(updatedCreation) - const result = new UpdatePendingCreation() - result.amount = parseInt(amount.toString()) - result.memo = updatedCreation.memo - result.date = updatedCreation.date - result.moderator = updatedCreation.moderator - result.creation = await getUserCreations(user.id) + if (isCreationValid(creations, amount, creationDateObj)) { + // TODO Check if open creation (of creationDate) + amount * 10000 <= 1000 - return result + pendingCreationToUpdate.amount = BigInt(amount * 10000) + pendingCreationToUpdate.memo = memo + pendingCreationToUpdate.date = new Date(creationDate) + pendingCreationToUpdate.moderator = moderator + + await loginPendingTasksAdminRepository.save(pendingCreationToUpdate) + const result = new UpdatePendingCreation() + result.amount = parseInt(amount.toString()) + result.memo = pendingCreationToUpdate.memo + result.date = pendingCreationToUpdate.date + result.moderator = pendingCreationToUpdate.moderator + result.creation = await getUserCreations(user.id) + + return result + } else { + throw new Error('Creation is not valid') + } } @Authorized([RIGHTS.SEARCH_PENDING_CREATION]) From afbc52c2aa79de2151e08058eae477b5a66ce915 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 26 Jan 2022 20:10:11 +0100 Subject: [PATCH 02/12] Implemented a method to add back the summ to the creations array. --- backend/src/graphql/resolver/AdminResolver.ts | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index d658fce2e..4e936a351 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -23,6 +23,7 @@ import { UserTransactionRepository } from '../../typeorm/repository/UserTransact import { BalanceRepository } from '../../typeorm/repository/Balance' import { calculateDecay } from '../../util/decay' import { LoginUserRepository } from '../../typeorm/repository/LoginUser' +import { LoginPendingTasksAdmin } from '@entity/LoginPendingTasksAdmin' @Resolver() export class AdminResolver { @@ -120,7 +121,8 @@ export class AdminResolver { } const creationDateObj = new Date(creationDate) - const creations = await getUserCreations(user.id) + let creations = await getUserCreations(user.id) + creations = updateCreations(creations, pendingCreationToUpdate) if (isCreationValid(creations, amount, creationDateObj)) { // TODO Check if open creation (of creationDate) + amount * 10000 <= 1000 @@ -332,6 +334,28 @@ async function getUserCreations(id: number): Promise { ] } +function updateCreations(creations: number[], pendingCreation: LoginPendingTasksAdmin): number[] { + const dateMonth = moment().format('YYYY-MM') + const dateLastMonth = moment().subtract(1, 'month').format('YYYY-MM') + const dateBeforeLastMonth = moment().subtract(2, 'month').format('YYYY-MM') + const creationDateMonth = moment(pendingCreation.date).format('YYYY-MM') + + switch (creationDateMonth) { + case dateMonth: + creations[2] += parseInt(pendingCreation.amount.toString()) + break + case dateLastMonth: + creations[1] += parseInt(pendingCreation.amount.toString()) + break + case dateBeforeLastMonth: + creations[0] += parseInt(pendingCreation.amount.toString()) + break + default: + throw new Error('UpdatedCreationDate is not in the last three months') + } + return creations +} + function isCreationValid(creations: number[], amount: number, creationDate: Date) { const dateMonth = moment().format('YYYY-MM') const dateLastMonth = moment().subtract(1, 'month').format('YYYY-MM') From 61c90737120e25938243e9039d3bd016d76fae23 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 27 Jan 2022 01:24:51 +0100 Subject: [PATCH 03/12] update configs and parameterize klicktipp options --- backend/.env.dist | 50 +++++++++++++++++++-------------- backend/.env.template | 39 ++++++++++++++++--------- deployment/bare_metal/.env.dist | 6 ++++ 3 files changed, 60 insertions(+), 35 deletions(-) diff --git a/backend/.env.dist b/backend/.env.dist index 785b2c15d..d556c82da 100644 --- a/backend/.env.dist +++ b/backend/.env.dist @@ -1,38 +1,46 @@ +# Server PORT=4000 JWT_SECRET=secret123 JWT_EXPIRES_IN=10m GRAPHIQL=false GDT_API_URL=https://gdt.gradido.net + +# Database DB_HOST=localhost DB_PORT=3306 DB_USER=root DB_PASSWORD= DB_DATABASE=gradido_community -TYPEORM_LOGGING_RELATIVE_PATH=typeorm.backend.log +TYPEORM_LOGGING_RELATIVE_PATHtypeorm.backend.log -#EMAIL=true -#EMAIL_USERNAME= -#EMAIL_SENDER= -#EMAIL_PASSWORD= -#EMAIL_SMTP_URL= -#EMAIL_SMTP_PORT=587 -#RESEND_TIME=1 minute, 60 => 1hour, 1440 (60 minutes * 24 hours) => 24 hours -#RESEND_TIME= -RESEND_TIME=10 +# Klicktipp +KLICKTIPP=false +KLICKTTIPP_API_URL=https://api.klicktipp.com +KLICKTIPP_USER=gradido_test +KLICKTIPP_PASSWORD=secret321 +KLICKTIPP_APIKEY_DE=SomeFakeKeyDE +KLICKTIPP_APIKEY_EN=SomeFakeKeyEN -#EMAIL_LINK_VERIFICATION=http://localhost/checkEmail/{code} -#EMAIL_LINK_SETPASSWORD=http://localhost/reset/{code} +# Community +COMMUNITY_NAME=Gradido Entwicklung +COMMUNITY_URL=http://localhost/ +COMMUNITY_REGISTER_URL=http://localhost/register +COMMUNITY_DESCRIPTION=Die lokale Entwicklungsumgebung von Gradido. -#KLICKTIPP_USER= -#KLICKTIPP_PASSWORD= -#KLICKTIPP_APIKEY_DE= -#KLICKTIPP_APIKEY_EN= -#KLICKTIPP=true -COMMUNITY_NAME= -COMMUNITY_URL= -COMMUNITY_REGISTER_URL= -COMMUNITY_DESCRIPTION= +# Login Server LOGIN_APP_SECRET=21ffbbc616fe LOGIN_SERVER_KEY=a51ef8ac7ef1abf162fb7a65261acd7a +# EMail +EMAIL=false +EMAIL_USERNAME=gradido_email +EMAIL_SENDER=info@gradido.net +EMAIL_PASSWORD=xxx +EMAIL_SMTP_URL=gmail.com +EMAIL_SMTP_PORT=587 +EMAIL_LINK_VERIFICATION=http://localhost/checkEmail/{code} +EMAIL_LINK_SETPASSWORD=http://localhost/reset/{code} +RESEND_TIME=10 + +# Webhook WEBHOOK_ELOPAGE_SECRET=secret \ No newline at end of file diff --git a/backend/.env.template b/backend/.env.template index 6507692b8..b3a5eb4c6 100644 --- a/backend/.env.template +++ b/backend/.env.template @@ -1,8 +1,10 @@ -PORT=4000 +# Server JWT_SECRET=$JWT_SECRET JWT_EXPIRES_IN=10m GRAPHIQL=false GDT_API_URL=$GDT_API_URL + +# Database DB_HOST=localhost DB_PORT=3306 DB_USER=$DB_USER @@ -10,26 +12,35 @@ DB_PASSWORD=$DB_PASSWORD DB_DATABASE=gradido_community TYPEORM_LOGGING_RELATIVE_PATH=$TYPEORM_LOGGING_RELATIVE_PATH +# Klicktipp +KLICKTIPP=$KLICKTIPP +KLICKTTIPP_API_URL=https://api.klicktipp.com +KLICKTIPP_USER=$KLICKTIPP_USER +KLICKTIPP_PASSWORD=$KLICKTIPP_PASSWORD +KLICKTIPP_APIKEY_DE=$KLICKTIPP_APIKEY_DE +KLICKTIPP_APIKEY_EN=$KLICKTIPP_APIKEY_EN + +# Community +COMMUNITY_NAME=$COMMUNITY_NAME +COMMUNITY_URL=$COMMUNITY_URL +COMMUNITY_REGISTER_URL=$COMMUNITY_REGISTER_URL +COMMUNITY_DESCRIPTION=$COMMUNITY_DESCRIPTION + +# Login Server +LOGIN_APP_SECRET=21ffbbc616fe +LOGIN_SERVER_KEY=a51ef8ac7ef1abf162fb7a65261acd7a + +# EMail +RESEND_TIME=10 EMAIL=$EMAIL EMAIL_USERNAME=$EMAIL_USERNAME EMAIL_SENDER=$EMAIL_SENDER EMAIL_PASSWORD=$EMAIL_PASSWORD EMAIL_SMTP_URL=$EMAIL_SMTP_URL EMAIL_SMTP_PORT=587 -#RESEND_TIME=1 minute, 60 => 1hour, 1440 (60 minutes * 24 hours) => 24 hours -RESEND_TIME=10 - EMAIL_LINK_VERIFICATION=$EMAIL_LINK_VERIFICATION EMAIL_LINK_SETPASSWORD=$EMAIL_LINK_SETPASSWORD +RESEND_TIME=10 -#KLICKTIPP_USER= -#KLICKTIPP_PASSWORD= -#KLICKTIPP_APIKEY_DE= -#KLICKTIPP_APIKEY_EN= -#KLICKTIPP=true -COMMUNITY_NAME=$COMMUNITY_NAME -COMMUNITY_URL=$COMMUNITY_URL -COMMUNITY_REGISTER_URL=$COMMUNITY_REGISTER_URL -COMMUNITY_DESCRIPTION=$COMMUNITY_DESCRIPTION - +# Webhook WEBHOOK_ELOPAGE_SECRET=$WEBHOOK_ELOPAGE_SECRET \ No newline at end of file diff --git a/deployment/bare_metal/.env.dist b/deployment/bare_metal/.env.dist index 6634284da..f69ce862e 100644 --- a/deployment/bare_metal/.env.dist +++ b/deployment/bare_metal/.env.dist @@ -37,6 +37,12 @@ COMMUNITY_URL=https://stage1.gradido.net/ COMMUNITY_REGISTER_URL=https://stage1.gradido.net/register COMMUNITY_DESCRIPTION=Gradido Development Stage1 Test Community +KLICKTIPP=false +KLICKTIPP_USER= +KLICKTIPP_PASSWORD= +KLICKTIPP_APIKEY_DE= +KLICKTIPP_APIKEY_EN= + # frontend GRAPHQL_URI=https://stage1.gradido.net/graphql ADMIN_AUTH_URL=https://stage1.gradido.net/admin/authenticate?token={token} From 795c99e64114c966c853bc8a07b69fffba9450c6 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 27 Jan 2022 01:24:58 +0100 Subject: [PATCH 04/12] flame hannes --- backend/src/config/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 7ca55eba1..5d5324808 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -43,6 +43,7 @@ const loginServer = { LOGIN_SERVER_KEY: process.env.LOGIN_SERVER_KEY || 'a51ef8ac7ef1abf162fb7a65261acd7a', } +// TODO: Hannes if I find you... this looks like blasphemy const resendTime = parseInt(process.env.RESEND_TIME ? process.env.RESEND_TIME : 'null') const email = { EMAIL: process.env.EMAIL === 'true' || false, From cc78849a46e3e59e4f7588639ba4f44121de6dae Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 27 Jan 2022 01:30:57 +0100 Subject: [PATCH 05/12] typo --- backend/.env.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/.env.dist b/backend/.env.dist index d556c82da..b1b16972f 100644 --- a/backend/.env.dist +++ b/backend/.env.dist @@ -11,7 +11,7 @@ DB_PORT=3306 DB_USER=root DB_PASSWORD= DB_DATABASE=gradido_community -TYPEORM_LOGGING_RELATIVE_PATHtypeorm.backend.log +TYPEORM_LOGGING_RELATIVE_PATH=typeorm.backend.log # Klicktipp KLICKTIPP=false From 18e1d1c224e8f4547328466ae6683147698e0039 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Thu, 27 Jan 2022 02:34:06 +0100 Subject: [PATCH 06/12] first draft of releaseplan --- .../2022-01-27_V-1.6.0_Releaseplan.md | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 docu/ReleasePlaning/2022-01-27_V-1.6.0_Releaseplan.md diff --git a/docu/ReleasePlaning/2022-01-27_V-1.6.0_Releaseplan.md b/docu/ReleasePlaning/2022-01-27_V-1.6.0_Releaseplan.md new file mode 100644 index 000000000..3f555e464 --- /dev/null +++ b/docu/ReleasePlaning/2022-01-27_V-1.6.0_Releaseplan.md @@ -0,0 +1,25 @@ +# Releaseplan V1.6.0 + +Die folgenden Schritte dienen zur Vorbereitung und Durchführung der Inbetriebnahme von Release V-1.6.0. + + +| LfdNr. | Aktion | verantwortlich | Status
(Ok / Err / Ongoing) | Startzeit | Dauer in min | Endezeit | +| ------ | ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | -------------------------------- | --------- | ------------ | -------- | +| 1 | Finish all PRs & Finally merge everything | **@Hannes** **@ogerly** **@moriz** **@ulfgebh** | | | | | +| 2 | Make a new version 1.6.0 | **@Developer** | | | | | +| 2a | Deploy V1.6.0 on Stage 2 and make Tests to confirm a working release build | **@Developer @Bernd von Gradido** | | | | | +| 3 | Setup Klicktip settings from old production on new production (?)Make a new version 1.6.0 | ****@ulfgebhardt** **@einhornimmon**** | | | | | +| 4 | Deploy 1.6.0 on gdd.gradido.net and make sure things work as expected(rudimentary) | **@ulfgebhardt** | | | | | +| 5a | Disable Klicktipp Hook to current production gdd1.gradido.com | **@einhornimmond** | | | | | +| 5b | Disable Elopage Hook to current production gdd1.gradido.com | **@einhornimmond** | | | | | +| 6 | Deploy Maintenance page to current production & enable it | **@einhornimmond** | | | | | +| 7 | Shut down current production servers except mariadb & nginx serving the maintenance page | **@einhornimmond** | | | | | +| 8 | Create backup from production (correct format & correct data) | **@einhornimmond** | | | | | +| 9 | Shut down mariadb server | **@einhornimmond** | | | | | +| 10 | Transmit backup to new production | **@ulfgebhardt** | | | | | +| 11 | Import production data on new production | **@ulfgebhardt** | | | | | +| 12a | Enable new Klicktipp hook to new production | **@einhornimmond** **@ulfgebhard** | | | | | +| 12b | Enable new Elopage hooks to new production | **@einhornimmond** **@ulfgebhard** | | | | | +| 13 | Do extended tests on the new production | **@Team** | | | | | +| 14 | Have a permanent redirect from all old urls to the new production server:
Which one?
- URL1
- URL2
- etc. | **@einhornimmond** | | | | | +| 15 | Update links on Wordpress to the new production server | **@Bernd von Gradido** | | | | | From 74fe7262141abfc8b0f62c350a1f6d26d19f9ab5 Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 27 Jan 2022 08:16:16 +0100 Subject: [PATCH 07/12] bootstrap version swapped from 5 to 4 --- admin/package.json | 4 ++-- admin/yarn.lock | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/admin/package.json b/admin/package.json index 93fbed8ae..e8d78d457 100644 --- a/admin/package.json +++ b/admin/package.json @@ -28,12 +28,12 @@ "babel-plugin-component": "^1.1.1", "babel-preset-env": "^1.7.0", "babel-preset-vue": "^2.0.2", - "bootstrap": "^5.1.3", + "bootstrap": "4.3.1", "bootstrap-vue": "^2.21.2", "core-js": "^3.6.5", "dotenv-webpack": "^7.0.3", - "graphql": "^15.6.1", "express": "^4.17.1", + "graphql": "^15.6.1", "identity-obj-proxy": "^3.0.0", "jest": "26.6.3", "moment": "^2.29.1", diff --git a/admin/yarn.lock b/admin/yarn.lock index 46b5aaa93..99768d3a2 100644 --- a/admin/yarn.lock +++ b/admin/yarn.lock @@ -3634,16 +3634,16 @@ bootstrap-vue@^2.21.2: portal-vue "^2.1.7" vue-functional-data-merge "^3.1.0" +bootstrap@4.3.1: + version "4.3.1" + resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-4.3.1.tgz#280ca8f610504d99d7b6b4bfc4b68cec601704ac" + integrity sha512-rXqOmH1VilAt2DyPzluTi2blhk17bO7ef+zLLPlWvG494pDxcM234pJ8wTc/6R40UWizAIIMgxjvxZg5kmsbag== + "bootstrap@>=4.5.3 <5.0.0": version "4.6.0" resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-4.6.0.tgz#97b9f29ac98f98dfa43bf7468262d84392552fd7" integrity sha512-Io55IuQY3kydzHtbGvQya3H+KorS/M9rSNyfCGCg9WZ4pyT/lCxIlpJgG1GXW/PswzC84Tr2fBYi+7+jFVQQBw== -bootstrap@^5.1.3: - version "5.1.3" - resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-5.1.3.tgz#ba081b0c130f810fa70900acbc1c6d3c28fa8f34" - integrity sha512-fcQztozJ8jToQWXxVuEyXWW+dSo8AiXWKwiSSrKWsRB/Qt+Ewwza+JWoLKiTuQLaEPhdNAJ7+Dosc9DOIqNy7Q== - brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" From e65e5078f9bfcd6842236f2543a2eaeca9ddc783 Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 27 Jan 2022 08:58:43 +0100 Subject: [PATCH 08/12] style change CreationFormular.vue for bootstrap4 --- admin/src/components/CreationFormular.vue | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/admin/src/components/CreationFormular.vue b/admin/src/components/CreationFormular.vue index 49993d14a..6d1c732ff 100644 --- a/admin/src/components/CreationFormular.vue +++ b/admin/src/components/CreationFormular.vue @@ -3,9 +3,10 @@ {{ $t('creation_form.form') }}
- - - +
+ + + - + - +
@@ -71,8 +72,8 @@ >
- - +
+
- +
- + {{ $t('creation_form.reset') }} From 14efa9f072e545b1f333fdc58b6f0cc582e9370c Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 27 Jan 2022 08:59:52 +0100 Subject: [PATCH 09/12] yarn lint fix for CreationFormular.vue --- admin/src/components/CreationFormular.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/admin/src/components/CreationFormular.vue b/admin/src/components/CreationFormular.vue index 6d1c732ff..3c8c914e2 100644 --- a/admin/src/components/CreationFormular.vue +++ b/admin/src/components/CreationFormular.vue @@ -3,9 +3,10 @@ {{ $t('creation_form.form') }}
-
+
+ +
- Date: Thu, 27 Jan 2022 09:02:53 +0100 Subject: [PATCH 10/12] style change EditCreationFormular.vue for bootstrap4 --- admin/src/components/EditCreationFormular.vue | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/admin/src/components/EditCreationFormular.vue b/admin/src/components/EditCreationFormular.vue index 172ae5509..2fa45dd8e 100644 --- a/admin/src/components/EditCreationFormular.vue +++ b/admin/src/components/EditCreationFormular.vue @@ -2,8 +2,10 @@
- +
+
+ - +
@@ -85,8 +87,8 @@ >
- - +
+
- +
- + {{ $t('creation_form.reset') }} From 7d596651fa0de85e83d470c8f57c575039384871 Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 27 Jan 2022 09:33:29 +0100 Subject: [PATCH 11/12] =?UTF-8?q?Rechtschreibfehler=20behoben,=20entg?= =?UTF-8?q?=C3=BCltig=20zu=20endg=C3=BCltig?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/locales/de.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/src/locales/de.json b/admin/src/locales/de.json index b1a008eaf..ff1a453ce 100644 --- a/admin/src/locales/de.json +++ b/admin/src/locales/de.json @@ -39,7 +39,7 @@ "overlay": { "confirm": { "no": "Nein, nicht speichern.", - "question": "Willst du diese vorgespeicherte Schöpfung wirklich vollziehen und entgültig speichern?", + "question": "Willst du diese vorgespeicherte Schöpfung wirklich vollziehen und endgültig speichern?", "text": "Nach dem Speichern ist der Datensatz nicht mehr änderbar und kann auch nicht mehr gelöscht werden. Bitte überprüfe genau, dass alles stimmt.", "title": "Schöpfung bestätigen!", "yes": "Ja, Schöpfung bestätigen und speichern!" From 6c81673a4b36153578e43eb0256071565040594c Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 27 Jan 2022 11:04:32 +0100 Subject: [PATCH 12/12] Update creations of a user only if the old pending creation has the same month as the updated month. Throw exception before end of file. --- backend/src/graphql/resolver/AdminResolver.ts | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index 4e936a351..9ca558a9c 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -122,28 +122,27 @@ export class AdminResolver { const creationDateObj = new Date(creationDate) let creations = await getUserCreations(user.id) - creations = updateCreations(creations, pendingCreationToUpdate) + if (pendingCreationToUpdate.date.getMonth() === creationDateObj.getMonth()) { + creations = updateCreations(creations, pendingCreationToUpdate) + } - if (isCreationValid(creations, amount, creationDateObj)) { - // TODO Check if open creation (of creationDate) + amount * 10000 <= 1000 - - pendingCreationToUpdate.amount = BigInt(amount * 10000) - pendingCreationToUpdate.memo = memo - pendingCreationToUpdate.date = new Date(creationDate) - pendingCreationToUpdate.moderator = moderator - - await loginPendingTasksAdminRepository.save(pendingCreationToUpdate) - const result = new UpdatePendingCreation() - result.amount = parseInt(amount.toString()) - result.memo = pendingCreationToUpdate.memo - result.date = pendingCreationToUpdate.date - result.moderator = pendingCreationToUpdate.moderator - result.creation = await getUserCreations(user.id) - - return result - } else { + if (!isCreationValid(creations, amount, creationDateObj)) { throw new Error('Creation is not valid') } + pendingCreationToUpdate.amount = BigInt(amount * 10000) + pendingCreationToUpdate.memo = memo + pendingCreationToUpdate.date = new Date(creationDate) + pendingCreationToUpdate.moderator = moderator + + await loginPendingTasksAdminRepository.save(pendingCreationToUpdate) + const result = new UpdatePendingCreation() + result.amount = parseInt(amount.toString()) + result.memo = pendingCreationToUpdate.memo + result.date = pendingCreationToUpdate.date + result.moderator = pendingCreationToUpdate.moderator + result.creation = await getUserCreations(user.id) + + return result } @Authorized([RIGHTS.SEARCH_PENDING_CREATION])