From b70565cabf0d888c4038043cb90262ebdce8f75d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Thu, 26 Jan 2023 00:33:42 +0100 Subject: [PATCH 001/373] remove TestResolvers from previous PR "multiple graphql endpoints" --- .../src/graphql/api/1_0/resolver/Test2Resolver.ts | 12 ------------ .../src/graphql/api/1_0/resolver/TestResolver.ts | 12 ------------ .../src/graphql/api/1_1/resolver/TestResolver.ts | 12 ------------ .../src/graphql/api/2_0/resolver/TestResolver.ts | 12 ------------ 4 files changed, 48 deletions(-) delete mode 100644 federation/src/graphql/api/1_0/resolver/Test2Resolver.ts delete mode 100644 federation/src/graphql/api/1_0/resolver/TestResolver.ts delete mode 100644 federation/src/graphql/api/1_1/resolver/TestResolver.ts delete mode 100644 federation/src/graphql/api/2_0/resolver/TestResolver.ts diff --git a/federation/src/graphql/api/1_0/resolver/Test2Resolver.ts b/federation/src/graphql/api/1_0/resolver/Test2Resolver.ts deleted file mode 100644 index 3388003b8..000000000 --- a/federation/src/graphql/api/1_0/resolver/Test2Resolver.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Query, Resolver } from 'type-graphql' -import { federationLogger as logger } from '@/server/logger' -import { GetTestApiResult } from '../../GetTestApiResult' - -@Resolver() -export class Test2Resolver { - @Query(() => GetTestApiResult) - async test2(): Promise { - logger.info(`test api 2 1_0`) - return new GetTestApiResult('1_0') - } -} diff --git a/federation/src/graphql/api/1_0/resolver/TestResolver.ts b/federation/src/graphql/api/1_0/resolver/TestResolver.ts deleted file mode 100644 index 7291e5ef2..000000000 --- a/federation/src/graphql/api/1_0/resolver/TestResolver.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Field, ObjectType, Query, Resolver } from 'type-graphql' -import { federationLogger as logger } from '@/server/logger' -import { GetTestApiResult } from '../../GetTestApiResult' - -@Resolver() -export class TestResolver { - @Query(() => GetTestApiResult) - async test(): Promise { - logger.info(`test api 1_0`) - return new GetTestApiResult('1_0') - } -} diff --git a/federation/src/graphql/api/1_1/resolver/TestResolver.ts b/federation/src/graphql/api/1_1/resolver/TestResolver.ts deleted file mode 100644 index 8880cad6e..000000000 --- a/federation/src/graphql/api/1_1/resolver/TestResolver.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Field, ObjectType, Query, Resolver } from 'type-graphql' -import { federationLogger as logger } from '@/server/logger' -import { GetTestApiResult } from '../../GetTestApiResult' - -@Resolver() -export class TestResolver { - @Query(() => GetTestApiResult) - async test(): Promise { - logger.info(`test api 1_1`) - return new GetTestApiResult('1_1') - } -} diff --git a/federation/src/graphql/api/2_0/resolver/TestResolver.ts b/federation/src/graphql/api/2_0/resolver/TestResolver.ts deleted file mode 100644 index f50149e33..000000000 --- a/federation/src/graphql/api/2_0/resolver/TestResolver.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Field, ObjectType, Query, Resolver } from 'type-graphql' -import { federationLogger as logger } from '@/server/logger' -import { GetTestApiResult } from '../../GetTestApiResult' - -@Resolver() -export class TestResolver { - @Query(() => GetTestApiResult) - async test(): Promise { - logger.info(`test api 2_0`) - return new GetTestApiResult('2_0') - } -} From a05c2307ee4becd498ec85509d09e213810e5a41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Thu, 26 Jan 2023 00:34:45 +0100 Subject: [PATCH 002/373] add columns to communities table --- backend/src/config/index.ts | 2 +- .../Community.ts | 48 +++++++++++++++++++ database/entity/Community.ts | 2 +- .../0060-update_communities_table.ts | 22 +++++++++ federation/src/config/index.ts | 2 +- 5 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 database/entity/0060-update_communities_table/Community.ts create mode 100644 database/migrations/0060-update_communities_table.ts diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index d010b4ab0..3b8d0d1d6 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0059-add_hide_amount_to_users', + DB_VERSION: '0060-update_communities_table', DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0 LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info diff --git a/database/entity/0060-update_communities_table/Community.ts b/database/entity/0060-update_communities_table/Community.ts new file mode 100644 index 000000000..3a9082667 --- /dev/null +++ b/database/entity/0060-update_communities_table/Community.ts @@ -0,0 +1,48 @@ +import { + BaseEntity, + Entity, + PrimaryGeneratedColumn, + Column, + CreateDateColumn, + UpdateDateColumn, +} from 'typeorm' + +@Entity('communities') +export class Community extends BaseEntity { + @PrimaryGeneratedColumn('increment', { unsigned: true }) + id: number + + @Column({ name: 'foreign', type: 'bool', nullable: false, default: false }) + foreign: boolean + + @Column({ name: 'public_key', type: 'binary', length: 64, default: null, nullable: true }) + publicKey: Buffer + + @Column({ name: 'api_version', length: 10, nullable: false }) + apiVersion: string + + @Column({ name: 'end_point', length: 255, nullable: false }) + endPoint: string + + @Column({ name: 'last_announced_at', type: 'datetime', nullable: false }) + lastAnnouncedAt: Date + + @Column({ name: 'pubkey_verified_at', type: 'datetime', nullable: false }) + pubKeyVerifiedAt: Date + + @CreateDateColumn({ + name: 'created_at', + type: 'datetime', + default: () => 'CURRENT_TIMESTAMP(3)', + nullable: false, + }) + createdAt: Date + + @UpdateDateColumn({ + name: 'updated_at', + type: 'datetime', + onUpdate: 'CURRENT_TIMESTAMP(3)', + nullable: true, + }) + updatedAt: Date | null +} diff --git a/database/entity/Community.ts b/database/entity/Community.ts index 457d03eae..80e5ace30 100644 --- a/database/entity/Community.ts +++ b/database/entity/Community.ts @@ -1 +1 @@ -export { Community } from './0058-add_communities_table/Community' +export { Community } from './0060-update_communities_table/Community' diff --git a/database/migrations/0060-update_communities_table.ts b/database/migrations/0060-update_communities_table.ts new file mode 100644 index 000000000..1047481ee --- /dev/null +++ b/database/migrations/0060-update_communities_table.ts @@ -0,0 +1,22 @@ +/* MIGRATION TO CREATE THE FEDERATION COMMUNITY TABLES + * + * This migration creates the `community` and 'communityfederation' tables in the `apollo` database (`gradido_community`). + */ + +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/* eslint-disable @typescript-eslint/no-explicit-any */ + +export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn( + 'ALTER TABLE `communities` ADD COLUMN `foreign` tinyint(4) NOT NULL DEFAULT 0 AFTER `id`;', + ) + await queryFn( + 'ALTER TABLE `communities` ADD COLUMN `pubkey_verified_at` datetime(3) AFTER `last_announced_at`;', + ) +} + +export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { + // write downgrade logic as parameter of queryFn + await queryFn('ALTER TABLE communities DROP COLUMN foreign;') + await queryFn('ALTER TABLE communities DROP COLUMN pubkey_verified_at;') +} diff --git a/federation/src/config/index.ts b/federation/src/config/index.ts index c2d81d2c8..2404c610f 100644 --- a/federation/src/config/index.ts +++ b/federation/src/config/index.ts @@ -11,7 +11,7 @@ Decimal.set({ */ const constants = { - DB_VERSION: '0059-add_hide_amount_to_users', + DB_VERSION: '0060-update_communities_table', // DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0 LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info From 4e1a6d965e620311c4d2f9678901accaa5299e56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Thu, 26 Jan 2023 00:35:28 +0100 Subject: [PATCH 003/373] create graphql endpoint for GetPublicKey request --- .../api/1_0/model/GetPublicKeyResult.ts | 11 +++++++++++ .../api/1_0/resolver/PublicKeyResolver.ts | 18 ++++++++++++++++++ federation/src/graphql/api/GetTestApiResult.ts | 11 ----------- 3 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 federation/src/graphql/api/1_0/model/GetPublicKeyResult.ts create mode 100644 federation/src/graphql/api/1_0/resolver/PublicKeyResolver.ts delete mode 100644 federation/src/graphql/api/GetTestApiResult.ts diff --git a/federation/src/graphql/api/1_0/model/GetPublicKeyResult.ts b/federation/src/graphql/api/1_0/model/GetPublicKeyResult.ts new file mode 100644 index 000000000..1582ad892 --- /dev/null +++ b/federation/src/graphql/api/1_0/model/GetPublicKeyResult.ts @@ -0,0 +1,11 @@ +import { Field, ObjectType } from 'type-graphql' + +@ObjectType() +export class GetPublicKeyResult { + constructor(pubKey: string) { + this.publicKey = pubKey + } + + @Field(() => String) + publicKey: string +} diff --git a/federation/src/graphql/api/1_0/resolver/PublicKeyResolver.ts b/federation/src/graphql/api/1_0/resolver/PublicKeyResolver.ts new file mode 100644 index 000000000..53f0d0bd4 --- /dev/null +++ b/federation/src/graphql/api/1_0/resolver/PublicKeyResolver.ts @@ -0,0 +1,18 @@ +import { Field, ObjectType, Query, Resolver } from 'type-graphql' +import { federationLogger as logger } from '@/server/logger' +import { Community as DbCommunity } from '@entity/Community' +import { GetPublicKeyResult } from '../model/GetPublicKeyResult' + +@Resolver() +export class PublicKeyResolver { + @Query(() => GetPublicKeyResult) + async getPublicKey(): Promise { + logger.info(`getPublicKey()...`) + const homeCom = await DbCommunity.findOneOrFail({ + foreign: false, + apiVersion: '1_0', + }) + logger.info(`getPublicKey()... with publicKey=${homeCom.publicKey}`) + return new GetPublicKeyResult(homeCom.publicKey.toString()) + } +} diff --git a/federation/src/graphql/api/GetTestApiResult.ts b/federation/src/graphql/api/GetTestApiResult.ts deleted file mode 100644 index 7c8c6c487..000000000 --- a/federation/src/graphql/api/GetTestApiResult.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Field, ObjectType } from 'type-graphql' - -@ObjectType() -export class GetTestApiResult { - constructor(apiVersion: string) { - this.api = apiVersion - } - - @Field(() => String) - api: string -} From ae2097ff71439eab415573420b565c4bf25a321d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Fri, 27 Jan 2023 21:55:43 +0100 Subject: [PATCH 004/373] rename pubkeyVerifiedAt to verifiedAt --- database/entity/0060-update_communities_table/Community.ts | 4 ++-- database/migrations/0060-update_communities_table.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/database/entity/0060-update_communities_table/Community.ts b/database/entity/0060-update_communities_table/Community.ts index 3a9082667..73f098f46 100644 --- a/database/entity/0060-update_communities_table/Community.ts +++ b/database/entity/0060-update_communities_table/Community.ts @@ -27,8 +27,8 @@ export class Community extends BaseEntity { @Column({ name: 'last_announced_at', type: 'datetime', nullable: false }) lastAnnouncedAt: Date - @Column({ name: 'pubkey_verified_at', type: 'datetime', nullable: false }) - pubKeyVerifiedAt: Date + @Column({ name: 'verified_at', type: 'datetime', nullable: false }) + verifiedAt: Date @CreateDateColumn({ name: 'created_at', diff --git a/database/migrations/0060-update_communities_table.ts b/database/migrations/0060-update_communities_table.ts index 1047481ee..1e1b8411e 100644 --- a/database/migrations/0060-update_communities_table.ts +++ b/database/migrations/0060-update_communities_table.ts @@ -11,12 +11,12 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis 'ALTER TABLE `communities` ADD COLUMN `foreign` tinyint(4) NOT NULL DEFAULT 0 AFTER `id`;', ) await queryFn( - 'ALTER TABLE `communities` ADD COLUMN `pubkey_verified_at` datetime(3) AFTER `last_announced_at`;', + 'ALTER TABLE `communities` ADD COLUMN `verified_at` datetime(3) AFTER `last_announced_at`;', ) } export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { // write downgrade logic as parameter of queryFn await queryFn('ALTER TABLE communities DROP COLUMN foreign;') - await queryFn('ALTER TABLE communities DROP COLUMN pubkey_verified_at;') + await queryFn('ALTER TABLE communities DROP COLUMN verified_at;') } From b542f6c81e8a2b1c38e1a394a289851b1b106b9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Tue, 31 Jan 2023 01:02:20 +0100 Subject: [PATCH 005/373] add column last_error_at --- database/entity/0060-update_communities_table/Community.ts | 3 +++ database/migrations/0060-update_communities_table.ts | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/database/entity/0060-update_communities_table/Community.ts b/database/entity/0060-update_communities_table/Community.ts index 73f098f46..227400fdf 100644 --- a/database/entity/0060-update_communities_table/Community.ts +++ b/database/entity/0060-update_communities_table/Community.ts @@ -30,6 +30,9 @@ export class Community extends BaseEntity { @Column({ name: 'verified_at', type: 'datetime', nullable: false }) verifiedAt: Date + @Column({ name: 'last_error_at', type: 'datetime', nullable: false }) + lastErrorAt: Date + @CreateDateColumn({ name: 'created_at', type: 'datetime', diff --git a/database/migrations/0060-update_communities_table.ts b/database/migrations/0060-update_communities_table.ts index 1e1b8411e..55617fd0a 100644 --- a/database/migrations/0060-update_communities_table.ts +++ b/database/migrations/0060-update_communities_table.ts @@ -13,10 +13,14 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis await queryFn( 'ALTER TABLE `communities` ADD COLUMN `verified_at` datetime(3) AFTER `last_announced_at`;', ) + await queryFn( + 'ALTER TABLE `communities` ADD COLUMN `last_error_at` datetime(3) AFTER `verified_at`;', + ) } export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { // write downgrade logic as parameter of queryFn await queryFn('ALTER TABLE communities DROP COLUMN foreign;') await queryFn('ALTER TABLE communities DROP COLUMN verified_at;') + await queryFn('ALTER TABLE communities DROP COLUMN last_error_at;') } From 72f882add3ffade6dd3c0dd67bca0048a1ad987f Mon Sep 17 00:00:00 2001 From: clauspeterhuebner <86960882+clauspeterhuebner@users.noreply.github.com> Date: Tue, 7 Feb 2023 22:34:30 +0100 Subject: [PATCH 006/373] Update database/migrations/0060-update_communities_table.ts Co-authored-by: Moriz Wahl --- database/migrations/0060-update_communities_table.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/migrations/0060-update_communities_table.ts b/database/migrations/0060-update_communities_table.ts index 55617fd0a..1804ee6c7 100644 --- a/database/migrations/0060-update_communities_table.ts +++ b/database/migrations/0060-update_communities_table.ts @@ -8,7 +8,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { await queryFn( - 'ALTER TABLE `communities` ADD COLUMN `foreign` tinyint(4) NOT NULL DEFAULT 0 AFTER `id`;', + 'ALTER TABLE `communities` ADD COLUMN `foreign` tinyint(4) NOT NULL DEFAULT 1 AFTER `id`;', ) await queryFn( 'ALTER TABLE `communities` ADD COLUMN `verified_at` datetime(3) AFTER `last_announced_at`;', From fcab712f86468e5a19311f9284acd99a404f3bfd Mon Sep 17 00:00:00 2001 From: clauspeterhuebner <86960882+clauspeterhuebner@users.noreply.github.com> Date: Tue, 7 Feb 2023 22:35:12 +0100 Subject: [PATCH 007/373] Update database/entity/0060-update_communities_table/Community.ts Co-authored-by: Moriz Wahl --- database/entity/0060-update_communities_table/Community.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/entity/0060-update_communities_table/Community.ts b/database/entity/0060-update_communities_table/Community.ts index 227400fdf..d764fc98f 100644 --- a/database/entity/0060-update_communities_table/Community.ts +++ b/database/entity/0060-update_communities_table/Community.ts @@ -12,7 +12,7 @@ export class Community extends BaseEntity { @PrimaryGeneratedColumn('increment', { unsigned: true }) id: number - @Column({ name: 'foreign', type: 'bool', nullable: false, default: false }) + @Column({ name: 'foreign', type: 'bool', nullable: false, default: true }) foreign: boolean @Column({ name: 'public_key', type: 'binary', length: 64, default: null, nullable: true }) From d38539df7ceda1cfcd6aeaaf2f6035f040d255a9 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 14 Feb 2023 12:09:29 +0100 Subject: [PATCH 008/373] Add yarn build on gradido folder, goes into database, admin, frontend, backend, e2e-tests and federation. --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 2220c1a85..626e3ed02 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "author": "Ulf Gebhardt ", "license": "Apache-2.0", "scripts": { - "release": "scripts/release.sh" + "release": "scripts/release.sh", + "build": "yarn && cd database && yarn && cd ../frontend && yarn && cd ../admin && yarn && cd ../backend && yarn && cd ../e2e-tests && yarn && cd ../federation && yarn && cd .." }, "dependencies": { "auto-changelog": "^2.4.0", From 8e85bf30d02ac4f2051618425543788d2ce9f9d6 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 15 Feb 2023 16:15:47 +0100 Subject: [PATCH 009/373] Rename build to install so we can install gradido under packages with this command. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 626e3ed02..86c345011 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "license": "Apache-2.0", "scripts": { "release": "scripts/release.sh", - "build": "yarn && cd database && yarn && cd ../frontend && yarn && cd ../admin && yarn && cd ../backend && yarn && cd ../e2e-tests && yarn && cd ../federation && yarn && cd .." + "install": "yarn && cd database && yarn && cd ../frontend && yarn && cd ../admin && yarn && cd ../backend && yarn && cd ../e2e-tests && yarn && cd ../federation && yarn && cd .." }, "dependencies": { "auto-changelog": "^2.4.0", From 4db4e63200dd30f90b045f224c77950f8a21e7e7 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 15 Feb 2023 16:18:31 +0100 Subject: [PATCH 010/373] With install it collide with the normal install. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 86c345011..e7fc91a96 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "license": "Apache-2.0", "scripts": { "release": "scripts/release.sh", - "install": "yarn && cd database && yarn && cd ../frontend && yarn && cd ../admin && yarn && cd ../backend && yarn && cd ../e2e-tests && yarn && cd ../federation && yarn && cd .." + "installAll": "yarn && cd database && yarn && cd ../frontend && yarn && cd ../admin && yarn && cd ../backend && yarn && cd ../e2e-tests && yarn && cd ../federation && yarn && cd .." }, "dependencies": { "auto-changelog": "^2.4.0", From 81daa8324437760e59c47eabdda9bc50832e3afa Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 15 Feb 2023 16:22:33 +0100 Subject: [PATCH 011/373] Add new command to the README. --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3d086018e..87b4f44e5 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,11 @@ git clone git@github.com:gradido/gradido.git git submodule update --recursive --init ``` -### 2. Run docker-compose +### 2. Install modules + +You can go in each under folder (admin, frontend, database, backend, ...) and call ``yarn`` in each folder or you can call ``yarn installAll``. + +### 3. Run docker-compose Run docker-compose to bring up the development environment From ddae7f647dc1f7aa1d1324f4fbd1a937bd6935ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Wed, 15 Feb 2023 23:11:16 +0100 Subject: [PATCH 012/373] describe and draw the current federation moduls and handshake --- .../TechnicalRequirements/Federation.md | 47 ++- .../graphics/TechnicalOverview_V1-19.drawio | 282 ++++++++++++++++++ .../image/TechnicalOverview_V1-19.svg | 1 + 3 files changed, 303 insertions(+), 27 deletions(-) create mode 100644 docu/Concepts/TechnicalRequirements/graphics/TechnicalOverview_V1-19.drawio create mode 100644 docu/Concepts/TechnicalRequirements/image/TechnicalOverview_V1-19.svg diff --git a/docu/Concepts/TechnicalRequirements/Federation.md b/docu/Concepts/TechnicalRequirements/Federation.md index 959aa8afe..7210756ff 100644 --- a/docu/Concepts/TechnicalRequirements/Federation.md +++ b/docu/Concepts/TechnicalRequirements/Federation.md @@ -4,29 +4,6 @@ This document contains the concept and technical details for the *federation* of But meanwhile the usage of a DHT like HyperSwarm promises more coverage of the gradido requirements out of the box. More details about HyperSwarm can be found here [@hyperswarm/dht](https://github.com/hyperswarm/dht). -## ActivityPub (deprecated) - -The activity pub defines a server-to-server federation protocol to share information between decentralized instances and will be the main komponent for the gradido community federation. - -At first we asume a *gradido community* as an *ActivityPub user*. A user is represented by "*actors*" via the users's accounts on servers. User's accounts on different servers corrsponds to different actors, which means community accounts on different servers corrsponds to different communities. - -Every community (actor) has an: - -* inbox: to get messages from the world -* outbox: to send messages to others - -and are simple endpoints or just URLs, which are described in the *ActivityStream* of each *ActivityPub community*. - -### Open Decision: - -It has to be decided, if the Federation will work with an internal or with external ActivityPub-Server, as shown in the picture below: - -![FederationActivityPub](./image/FederationActivityPub.png " ") - -The Variant A with an internal server contains the benefit to be as independent as possible from third party service providers and will not cause additional hosting costs. But this solution will cause the additional efforts of impementing an ActivityPub-Server in the gradido application and the responsibility for this component. - -The Varaint B with an external server contains the benefit to reduce the implementation efforts and the responsibility for an own ActivitPub-Server. But it will cause an additional dependency to a third party service provider and the growing hosting costs. - ## HyperSwarm The decision to switch from ActivityPub to HyperSwarm base on the arguments, that the *hyperswarm/dht* library will satify the most federation requirements out of the box. It is now to design the business requirements of the [gradido community communication](../BusinessRequirements/CommunityVerwaltung.md#UC-createCommunity) in a technical conception. @@ -41,12 +18,28 @@ To enable such a relationship between an existing community and a new community 2. Authentication 3. Autorized Communication -### Overview +### Overview of Federation-Handshake At first the following diagramm gives an overview of the three stages and shows the handshake between an existing community-A and a new created community-B including the data exchange for buildup such a federated, authenticated and autorized relationship. ![FederationHyperSwarm.png](./image/FederationHyperSwarm.png) +### Technical Architecture + +The previous described handshake will be done by several technical moduls of the gradido system. The following picture gives an overview about the moduls and how the communicate with each other. + +![img](./image/TechnicalOverview_V1-19.svg) + +As soon as a Gradido Community is up and running the DHT-Modul first write the home-community-entries in the database and starts with the federation per HyperSwarm. Each community, which is configured to listen on the GRADIDO_HUB of the DHT will be part of the Gradido-Net-Federation. That means each DHT-Modul of each community will receive the publicKey of all connected communities. The DHT-Modul will open for each received publicKey a communication-socket with the associated community DHT-Modul, to exchange api-version info and hosted urls for later direct communication between both communities. The exchanged api-version info and urls will be written in the own database. + +The up and running Backend-Modul contains a validation logic to verify the community entries from the own DHT-Modul. For each announced but unverified community-entry the GraphQL-Client is used to invoke a getPublicKey-Request. Depending on the containing api-version the matching GraphQL-Client is used and the getPublicKey-Request will be send to the given URL. + +As soon as the FederationModul of the assoziated community received the getPublicKey-request the own publicKey is read from database and send back in the response. + +The GraphQL-Client will read from the returned response data the publicKey of the other community and compare it with the data of the community-entry, which cause the getPublicKey-Request. If they match the community-entry will be updated be inserting the current timestamp in the verifiedAt-field of this community-entry. + +This federation and verification logic will work the whole time and can be monitored by observing the communities-table changes. The Admin-UI will contain a Page to have a look on the current state of the communities table content. + ### Prerequisits Before starting in describing the details of the federation handshake, some prerequisits have to be defined. @@ -235,7 +228,7 @@ For the first federation release the *DHT-Node* will be part of the *apollo serv | communityApiVersion.apiversion | keep existing value | | communityApiVersion.validFrom | exchangedData.API.validFrom | | communityApiVersion.verifiedAt | keep existing value | - * + * 3. After all received data is stored successfully, the *DHT-Node* starts the *stage2 - Authentication* of the federation handshake ### Stage2 - Authentication @@ -284,8 +277,8 @@ As soon the *openConnection* request is invoked: 3. check if the decrypted `parameter.signedAndEncryptedURL` is equals the selected url from the previous selected CommunityFederationEntry 1. if not then break the further processing of this request by only writing an error-log event. There will be no answer to the invoker community, because this community will only go on with a `openConnectionRedirect`-request from this community. 2. if yes then verify the signature of `parameter.signedAndEncryptedURL` with the `cf.pubKey` read in step 2 before - 3. -4. + 3. +4. ### Stage3 - Autorized Business Communication diff --git a/docu/Concepts/TechnicalRequirements/graphics/TechnicalOverview_V1-19.drawio b/docu/Concepts/TechnicalRequirements/graphics/TechnicalOverview_V1-19.drawio new file mode 100644 index 000000000..534804e1d --- /dev/null +++ b/docu/Concepts/TechnicalRequirements/graphics/TechnicalOverview_V1-19.drawio @@ -0,0 +1,282 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docu/Concepts/TechnicalRequirements/image/TechnicalOverview_V1-19.svg b/docu/Concepts/TechnicalRequirements/image/TechnicalOverview_V1-19.svg new file mode 100644 index 000000000..4b407aa5a --- /dev/null +++ b/docu/Concepts/TechnicalRequirements/image/TechnicalOverview_V1-19.svg @@ -0,0 +1 @@ +
Community  "Gradido-Akademie"
Community  "Gradido-Akademie"
Gradido - technical Infrastructure-Overview
State of 02.2023
Gradido - technical Infrastructure-Overview...
Backend-Modul
GraphQL-API
Backend-Modul...
CommunityServer DB
CommunityServer DB
Layer 1:
Layer 1:
Layer 2:
Layer 2:
"GDT-Server"
base on C++ + mySQL
"GDT-Server"...
GDT-Server DB
GDT-Server DB
json-
ajax-
request
json-...
Layer 3:
Layer 3:
"Elopage"
external Service-Portal
"Elopage"...
"User-UI"
"User-UI"
graphql
graphql
json-
request
json-...
graphql
graphql
"Admin-UI"
"Admin-UI"
DHT-Modul
HyperSwarm
DHT-Modul...
Federation-Modul
GraphQL-API V2_0
Federation-Modul...
Federation-Modul
GraphQL-API V1_x
Federation-Modul...
Federation-Modul
GraphQL-API V1_1
Federation-Modul...
Federation-Modul
GraphQL-API V1_0
Federation-Modul...
GraphQL-Client V1_0
GraphQL-Client V1_0
GraphQL-Client V1_0
GraphQL-Client V1_0
GraphQL-Client V1_0
GraphQL-Client V1_0
GraphQL-Client V1_0
GraphQL-Client V1_0
Community "GallischesDorf-TBB"
Community "GallischesDorf-TBB"
Backend-Modul
GraphQL-API
Backend-Modul...
CommunityServer DB
CommunityServer DB
Layer 1:
Layer 1:
Layer 2:
Layer 2:
Layer 3:
Layer 3:
"User-UI"
"User-UI"
graphql
graphql
graphql
graphql
"Admin-UI"
"Admin-UI"
 DHT-Socket Communication 
 DHT-Socket Communication 
DHT-Modul
HyperSwarm
DHT-Modul...
Federation-Modul
GraphQL-API V1_1
Federation-Modul...
Federation-Modul
GraphQL-API V1_0
Federation-Modul...
graphQL-Handshake
graphQL-Handshake
GraphQL-Client V1_1
GraphQL-Client V1_1
graphQL-Handshake
graphQL-Handshake
GraphQL-Client V1_0
GraphQL-Client V1_0
graphQL-Handshake
graphQL-Handshake
graphQL-Handshake
graphQL-Handshake
Viewer does not support full SVG 1.1
\ No newline at end of file From d6044b4fe61bd26ec0ba7318523d12c1318bbb22 Mon Sep 17 00:00:00 2001 From: Einhornimmond Date: Thu, 16 Feb 2023 14:46:12 +0100 Subject: [PATCH 013/373] correct error with gdt server in graphic --- .../graphics/TechnicalOverview_V1-19.drawio | 144 +++++++++--------- .../image/TechnicalOverview_V1-19.svg | 2 +- 2 files changed, 73 insertions(+), 73 deletions(-) diff --git a/docu/Concepts/TechnicalRequirements/graphics/TechnicalOverview_V1-19.drawio b/docu/Concepts/TechnicalRequirements/graphics/TechnicalOverview_V1-19.drawio index 534804e1d..3ce2508d9 100644 --- a/docu/Concepts/TechnicalRequirements/graphics/TechnicalOverview_V1-19.drawio +++ b/docu/Concepts/TechnicalRequirements/graphics/TechnicalOverview_V1-19.drawio @@ -1,277 +1,277 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/docu/Concepts/TechnicalRequirements/image/TechnicalOverview_V1-19.svg b/docu/Concepts/TechnicalRequirements/image/TechnicalOverview_V1-19.svg index 4b407aa5a..2f5264182 100644 --- a/docu/Concepts/TechnicalRequirements/image/TechnicalOverview_V1-19.svg +++ b/docu/Concepts/TechnicalRequirements/image/TechnicalOverview_V1-19.svg @@ -1 +1 @@ -
Community  "Gradido-Akademie"
Community  "Gradido-Akademie"
Gradido - technical Infrastructure-Overview
State of 02.2023
Gradido - technical Infrastructure-Overview...
Backend-Modul
GraphQL-API
Backend-Modul...
CommunityServer DB
CommunityServer DB
Layer 1:
Layer 1:
Layer 2:
Layer 2:
"GDT-Server"
base on C++ + mySQL
"GDT-Server"...
GDT-Server DB
GDT-Server DB
json-
ajax-
request
json-...
Layer 3:
Layer 3:
"Elopage"
external Service-Portal
"Elopage"...
"User-UI"
"User-UI"
graphql
graphql
json-
request
json-...
graphql
graphql
"Admin-UI"
"Admin-UI"
DHT-Modul
HyperSwarm
DHT-Modul...
Federation-Modul
GraphQL-API V2_0
Federation-Modul...
Federation-Modul
GraphQL-API V1_x
Federation-Modul...
Federation-Modul
GraphQL-API V1_1
Federation-Modul...
Federation-Modul
GraphQL-API V1_0
Federation-Modul...
GraphQL-Client V1_0
GraphQL-Client V1_0
GraphQL-Client V1_0
GraphQL-Client V1_0
GraphQL-Client V1_0
GraphQL-Client V1_0
GraphQL-Client V1_0
GraphQL-Client V1_0
Community "GallischesDorf-TBB"
Community "GallischesDorf-TBB"
Backend-Modul
GraphQL-API
Backend-Modul...
CommunityServer DB
CommunityServer DB
Layer 1:
Layer 1:
Layer 2:
Layer 2:
Layer 3:
Layer 3:
"User-UI"
"User-UI"
graphql
graphql
graphql
graphql
"Admin-UI"
"Admin-UI"
 DHT-Socket Communication 
 DHT-Socket Communication 
DHT-Modul
HyperSwarm
DHT-Modul...
Federation-Modul
GraphQL-API V1_1
Federation-Modul...
Federation-Modul
GraphQL-API V1_0
Federation-Modul...
graphQL-Handshake
graphQL-Handshake
GraphQL-Client V1_1
GraphQL-Client V1_1
graphQL-Handshake
graphQL-Handshake
GraphQL-Client V1_0
GraphQL-Client V1_0
graphQL-Handshake
graphQL-Handshake
graphQL-Handshake
graphQL-Handshake
Viewer does not support full SVG 1.1
\ No newline at end of file +
Community  "Gradido-Akademie"
Community  "Gradido-Akademie"
Gradido - technical Infrastructure-Overview
State of 02.2023
Gradido - technical Infrastructure-Overview...
Backend-Modul
GraphQL-API
Backend-Modul...
CommunityServer DB
CommunityServer DB
Layer 1:
Layer 1:
Layer 2:
Layer 2:
"GDT-Server"
base on cakephp + mySQL
"GDT-Server"...
GDT-Server DB
GDT-Server DB
json-
ajax-
request
json-...
Layer 3:
Layer 3:
"Elopage"
external Service-Portal
"Elopage"...
"User-UI"
"User-UI"
graphql
graphql
json-
request
json-...
graphql
graphql
"Admin-UI"
"Admin-UI"
DHT-Modul
HyperSwarm
DHT-Modul...
Federation-Modul
GraphQL-API V2_0
Federation-Modul...
Federation-Modul
GraphQL-API V1_x
Federation-Modul...
Federation-Modul
GraphQL-API V1_1
Federation-Modul...
Federation-Modul
GraphQL-API V1_0
Federation-Modul...
GraphQL-Client V1_0
GraphQL-Client V1_0
GraphQL-Client V1_0
GraphQL-Client V1_0
GraphQL-Client V1_0
GraphQL-Client V1_0
GraphQL-Client V1_0
GraphQL-Client V1_0
Community "GallischesDorf-TBB"
Community "GallischesDorf-TBB"
Backend-Modul
GraphQL-API
Backend-Modul...
CommunityServer DB
CommunityServer DB
Layer 1:
Layer 1:
Layer 2:
Layer 2:
Layer 3:
Layer 3:
"User-UI"
"User-UI"
graphql
graphql
graphql
graphql
"Admin-UI"
"Admin-UI"
 DHT-Socket Communication 
 DHT-Socket Communication 
DHT-Modul
HyperSwarm
DHT-Modul...
Federation-Modul
GraphQL-API V1_1
Federation-Modul...
Federation-Modul
GraphQL-API V1_0
Federation-Modul...
graphQL-Handshake
graphQL-Handshake
GraphQL-Client V1_1
GraphQL-Client V1_1
graphQL-Handshake
graphQL-Handshake
GraphQL-Client V1_0
GraphQL-Client V1_0
graphQL-Handshake
graphQL-Handshake
graphQL-Handshake
graphQL-Handshake
Text is not SVG - cannot display
\ No newline at end of file From 0d6fb2a427f1c294fe2c7cbca0f6f17180a2d6d5 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 16 Feb 2023 19:16:33 +0100 Subject: [PATCH 014/373] started event refactoring on database level --- .../entity/0061-event_refactoring/Event.ts | 82 +++++++++++++++++++ database/entity/Event.ts | 1 + database/entity/EventProtocol.ts | 1 - database/entity/index.ts | 8 +- database/migrations/0061-event_refactoring.ts | 33 ++++++++ 5 files changed, 120 insertions(+), 5 deletions(-) create mode 100644 database/entity/0061-event_refactoring/Event.ts create mode 100644 database/entity/Event.ts delete mode 100644 database/entity/EventProtocol.ts create mode 100644 database/migrations/0061-event_refactoring.ts diff --git a/database/entity/0061-event_refactoring/Event.ts b/database/entity/0061-event_refactoring/Event.ts new file mode 100644 index 000000000..62f517aba --- /dev/null +++ b/database/entity/0061-event_refactoring/Event.ts @@ -0,0 +1,82 @@ +import { Contribution } from '@entity/Contribution' +import { ContributionMessage } from '@entity/ContributionMessage' +import { User } from '@entity/User' +import Decimal from 'decimal.js-light' +import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, Transaction } from 'typeorm' +import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer' + +@Entity('event') +// TODO tablename event_protocol +export class Event extends BaseEntity { + @PrimaryGeneratedColumn('increment', { unsigned: true }) + id: number + + @Column({ length: 100, nullable: false, collation: 'utf8mb4_unicode_ci' }) + type: string + + // TODO proper field type + @Column({ name: 'created_at', type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) + createdAt: Date + + // TODO field name user_id + // @Column({ name: 'affected_user_id', unsigned: true, nullable: false }) + // affectedUserId: number + + @ManyToOne(() => User) + @JoinColumn({ name: 'affected_user_id', referencedColumnName: 'id' }) + affectedUser: User | null + + // TODO new column + // TODO potentially save actingRole aswell + // @Column({ name: 'acting_user_id', unsigned: true, nullable: false }) + // actingUserId: number + + @ManyToOne(() => User) + @JoinColumn({ name: 'acting_user_id', referencedColumnName: 'id' }) + actingUser: User | null + + // TODO rename column x_user_id + // @Column({ name: 'involved_user_id', type: 'int', unsigned: true, nullable: true }) + // involvedUserId: number | null + + @ManyToOne(() => User) + @JoinColumn({ name: 'involved_user_id', referencedColumnName: 'id' }) + involvedUser: User | null + + // TODO drop column xCommunityId + + // TODO rename column transaction_id + // @Column({ name: 'involved_transaction_id', type: 'int', unsigned: true, nullable: true }) + // involvedTransactionId: number | null + + @ManyToOne(() => Transaction) + @JoinColumn({ name: 'involved_transaction_id', referencedColumnName: 'id' }) + involvedTransaction: Transaction | null + + // TODO rename column contribution_id + // @Column({ name: 'involved_contribution_id', type: 'int', unsigned: true, nullable: true }) + // involvedContributionId: number | null + + @ManyToOne(() => Contribution) + @JoinColumn({ name: 'involved_contribution_id', referencedColumnName: 'id' }) + involvedContribution: Contribution | null + + // TODO move column + // TODO rename column message_id + // TEST do we need the Id field definition? + // @Column({ name: 'involved_contribution_message_id', type: 'int', unsigned: true, nullable: true }) + // involvedContributionMessageId: number | null + + @ManyToOne(() => ContributionMessage) + @JoinColumn({ name: 'involved_contribution_message_id', referencedColumnName: 'id' }) + involvedContributionMessage: ContributionMessage | null + + @Column({ + type: 'decimal', + precision: 40, + scale: 20, + nullable: true, + transformer: DecimalTransformer, + }) + amount: Decimal | null +} diff --git a/database/entity/Event.ts b/database/entity/Event.ts new file mode 100644 index 000000000..e53085f2f --- /dev/null +++ b/database/entity/Event.ts @@ -0,0 +1 @@ +export { Event } from './0061-event_refactoring/Event' diff --git a/database/entity/EventProtocol.ts b/database/entity/EventProtocol.ts deleted file mode 100644 index 6ebbd3d68..000000000 --- a/database/entity/EventProtocol.ts +++ /dev/null @@ -1 +0,0 @@ -export { EventProtocol } from './0050-add_messageId_to_event_protocol/EventProtocol' diff --git a/database/entity/index.ts b/database/entity/index.ts index a58afb816..2d9d04c3b 100644 --- a/database/entity/index.ts +++ b/database/entity/index.ts @@ -7,21 +7,21 @@ import { TransactionLink } from './TransactionLink' import { User } from './User' import { UserContact } from './UserContact' import { Contribution } from './Contribution' -import { EventProtocol } from './EventProtocol' +import { Event } from './Event' import { ContributionMessage } from './ContributionMessage' import { Community } from './Community' export const entities = [ + Community, Contribution, ContributionLink, + ContributionMessage, + Event, LoginElopageBuys, LoginEmailOptIn, Migration, Transaction, TransactionLink, User, - EventProtocol, - ContributionMessage, UserContact, - Community, ] diff --git a/database/migrations/0061-event_refactoring.ts b/database/migrations/0061-event_refactoring.ts new file mode 100644 index 000000000..a5ce50595 --- /dev/null +++ b/database/migrations/0061-event_refactoring.ts @@ -0,0 +1,33 @@ +/* MIGRATION TO REFACTOR THE EVENT_PROTOCOL TABLE + * + * This migration refactors the `event_protocol` table. + * It renames the table to `event`, introduces new fields and renames others. + */ + +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/* eslint-disable @typescript-eslint/no-explicit-any */ + +export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn( + 'ALTER TABLE `communities` MODIFY COLUMN `last_announced_at` datetime(3) AFTER `end_point`;', + ) + await queryFn( + 'ALTER TABLE `communities` ADD COLUMN `foreign` tinyint(4) NOT NULL DEFAULT 1 AFTER `id`;', + ) + await queryFn( + 'ALTER TABLE `communities` ADD COLUMN `verified_at` datetime(3) AFTER `last_announced_at`;', + ) + await queryFn( + 'ALTER TABLE `communities` ADD COLUMN `last_error_at` datetime(3) AFTER `verified_at`;', + ) +} + +export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { + // write downgrade logic as parameter of queryFn + await queryFn( + 'ALTER TABLE `communities` MODIFY COLUMN `last_announced_at` datetime(3) NOT NULL AFTER `end_point`;', + ) + await queryFn('ALTER TABLE `communities` DROP COLUMN `foreign`;') + await queryFn('ALTER TABLE `communities` DROP COLUMN `verified_at`;') + await queryFn('ALTER TABLE `communities` DROP COLUMN `last_error_at`;') +} From 225a8239ec028c4b1433800acc3affae7760c69b Mon Sep 17 00:00:00 2001 From: mahula Date: Fri, 17 Feb 2023 09:57:53 +0100 Subject: [PATCH 015/373] move all backend jobs to separate workflow file --- .github/workflows/test-admin-interface.yml | 69 ++++++++++++ .github/workflows/test.yml | 124 +-------------------- 2 files changed, 74 insertions(+), 119 deletions(-) create mode 100644 .github/workflows/test-admin-interface.yml diff --git a/.github/workflows/test-admin-interface.yml b/.github/workflows/test-admin-interface.yml new file mode 100644 index 000000000..d126a9075 --- /dev/null +++ b/.github/workflows/test-admin-interface.yml @@ -0,0 +1,69 @@ +name: Gradido Admin Interface Test CI + +on: + push: + branches: + - separate-admin-interface-workflow + +jobs: + build_test_admin: + name: Docker Build Test - Admin Interface + 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_admin: + name: Unit Tests - Admin Interface + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Admin Interface | Unit tests + run: | + cd admin && yarn && yarn run test + cp -r ./coverage ../ + + - 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 }} + + lint_admin: + name: Lint - Admin Interface + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Admin Interface | Lint + run: cd admin && yarn && yarn run lint + + stylelint_admin: + name: Stylelint - Admin Interface + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Admin Interface | Stylelint + run: cd admin && yarn && yarn run stylelint + + locales_admin: + name: Locales - Admin Interface + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Admin Interface | Locales + run: cd admin && yarn && yarn run locales diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index badb47e87..722bef1c1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,9 @@ name: gradido test CI -on: push +on: + push: + branches: + - separate-admin-interface-workflow jobs: ############################################################################## @@ -29,31 +32,6 @@ jobs: name: docker-frontend-test 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 ############################################# ############################################################################## @@ -211,60 +189,6 @@ jobs: - name: Frontend | 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 ########################################################## ############################################################################## @@ -349,37 +273,6 @@ jobs: 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 #################################################### @@ -459,7 +352,7 @@ jobs: end-to-end-tests: name: End-to-End Tests 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: ########################################################################## # CHECKOUT CODE ########################################################## @@ -490,13 +383,6 @@ jobs: path: /tmp - name: Load Docker Image (Frontend) 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) uses: actions/download-artifact@v3 with: From 80a059b94d3cfaf0d33796e36e4f6d4b5b21e1ac Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 17 Feb 2023 11:49:26 +0100 Subject: [PATCH 016/373] properly import entities --- database/entity/0061-event_refactoring/Event.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/database/entity/0061-event_refactoring/Event.ts b/database/entity/0061-event_refactoring/Event.ts index 62f517aba..ca2ab58da 100644 --- a/database/entity/0061-event_refactoring/Event.ts +++ b/database/entity/0061-event_refactoring/Event.ts @@ -1,6 +1,6 @@ -import { Contribution } from '@entity/Contribution' -import { ContributionMessage } from '@entity/ContributionMessage' -import { User } from '@entity/User' +import { Contribution } from '../Contribution' +import { ContributionMessage } from '../ContributionMessage' +import { User } from '../User' import Decimal from 'decimal.js-light' import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, Transaction } from 'typeorm' import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer' From 6d8b11aeb8f3f15ce627e8a5d8c6bcc193c614f7 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 17 Feb 2023 14:47:31 +0100 Subject: [PATCH 017/373] finished up Table definition and migration --- .../entity/0061-event_refactoring/Event.ts | 24 +++-------- database/migrations/0061-event_refactoring.ts | 43 ++++++++++++++----- 2 files changed, 39 insertions(+), 28 deletions(-) diff --git a/database/entity/0061-event_refactoring/Event.ts b/database/entity/0061-event_refactoring/Event.ts index ca2ab58da..80b4238bb 100644 --- a/database/entity/0061-event_refactoring/Event.ts +++ b/database/entity/0061-event_refactoring/Event.ts @@ -1,12 +1,12 @@ import { Contribution } from '../Contribution' import { ContributionMessage } from '../ContributionMessage' import { User } from '../User' +import { Transaction } from '../Transaction' import Decimal from 'decimal.js-light' -import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, Transaction } from 'typeorm' +import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, ManyToOne, JoinColumn } from 'typeorm' import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer' -@Entity('event') -// TODO tablename event_protocol +@Entity('events') export class Event extends BaseEntity { @PrimaryGeneratedColumn('increment', { unsigned: true }) id: number @@ -14,28 +14,24 @@ export class Event extends BaseEntity { @Column({ length: 100, nullable: false, collation: 'utf8mb4_unicode_ci' }) type: string - // TODO proper field type - @Column({ name: 'created_at', type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) + @CreateDateColumn({ name: 'created_at', type: 'datetime', default: () => 'CURRENT_TIMESTAMP()' , nullable: false }) createdAt: Date - // TODO field name user_id // @Column({ name: 'affected_user_id', unsigned: true, nullable: false }) // affectedUserId: number @ManyToOne(() => User) @JoinColumn({ name: 'affected_user_id', referencedColumnName: 'id' }) - affectedUser: User | null + affectedUser: User - // TODO new column - // TODO potentially save actingRole aswell + // TODO potentially save actingRole as well // @Column({ name: 'acting_user_id', unsigned: true, nullable: false }) // actingUserId: number @ManyToOne(() => User) @JoinColumn({ name: 'acting_user_id', referencedColumnName: 'id' }) - actingUser: User | null + actingUser: User - // TODO rename column x_user_id // @Column({ name: 'involved_user_id', type: 'int', unsigned: true, nullable: true }) // involvedUserId: number | null @@ -43,9 +39,6 @@ export class Event extends BaseEntity { @JoinColumn({ name: 'involved_user_id', referencedColumnName: 'id' }) involvedUser: User | null - // TODO drop column xCommunityId - - // TODO rename column transaction_id // @Column({ name: 'involved_transaction_id', type: 'int', unsigned: true, nullable: true }) // involvedTransactionId: number | null @@ -53,7 +46,6 @@ export class Event extends BaseEntity { @JoinColumn({ name: 'involved_transaction_id', referencedColumnName: 'id' }) involvedTransaction: Transaction | null - // TODO rename column contribution_id // @Column({ name: 'involved_contribution_id', type: 'int', unsigned: true, nullable: true }) // involvedContributionId: number | null @@ -61,8 +53,6 @@ export class Event extends BaseEntity { @JoinColumn({ name: 'involved_contribution_id', referencedColumnName: 'id' }) involvedContribution: Contribution | null - // TODO move column - // TODO rename column message_id // TEST do we need the Id field definition? // @Column({ name: 'involved_contribution_message_id', type: 'int', unsigned: true, nullable: true }) // involvedContributionMessageId: number | null diff --git a/database/migrations/0061-event_refactoring.ts b/database/migrations/0061-event_refactoring.ts index a5ce50595..88874b15e 100644 --- a/database/migrations/0061-event_refactoring.ts +++ b/database/migrations/0061-event_refactoring.ts @@ -8,26 +8,47 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn('RENAME TABLE `event_protocol` TO `events`;') + await queryFn('ALTER TABLE `events` RENAME COLUMN `user_id` TO `affected_user_id`;') + await queryFn( - 'ALTER TABLE `communities` MODIFY COLUMN `last_announced_at` datetime(3) AFTER `end_point`;', + 'ALTER TABLE `events` ADD COLUMN `acting_user_id` int(10) unsigned DEFAULT NULL AFTER `affected_user_id`;', + ) + await queryFn('UPDATE `events` SET `acting_user_id` = `affected_user_id`;') + await queryFn( + 'ALTER TABLE `events` MODIFY COLUMN `acting_user_id` int(10) unsigned NOT NULL AFTER `affected_user_id`;', + ) + + await queryFn('ALTER TABLE `events` RENAME COLUMN `x_user_id` TO `involved_user_id`;') + await queryFn('ALTER TABLE `events` DROP COLUMN `x_community_id`;') + await queryFn('ALTER TABLE `events` RENAME COLUMN `transaction_id` TO `involved_transaction_id`;') + await queryFn( + 'ALTER TABLE `events` RENAME COLUMN `contribution_id` TO `involved_contribution_id`;', ) await queryFn( - 'ALTER TABLE `communities` ADD COLUMN `foreign` tinyint(4) NOT NULL DEFAULT 1 AFTER `id`;', + 'ALTER TABLE `events` MODIFY COLUMN `message_id` int(10) unsigned DEFAULT NULL AFTER `involved_contribution_id`;', ) await queryFn( - 'ALTER TABLE `communities` ADD COLUMN `verified_at` datetime(3) AFTER `last_announced_at`;', - ) - await queryFn( - 'ALTER TABLE `communities` ADD COLUMN `last_error_at` datetime(3) AFTER `verified_at`;', + 'ALTER TABLE `events` RENAME COLUMN `message_id` TO `involved_contribution_message_id`;', ) } export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { - // write downgrade logic as parameter of queryFn await queryFn( - 'ALTER TABLE `communities` MODIFY COLUMN `last_announced_at` datetime(3) NOT NULL AFTER `end_point`;', + 'ALTER TABLE `events` RENAME COLUMN `involved_contribution_message_id` TO `message_id`;', ) - await queryFn('ALTER TABLE `communities` DROP COLUMN `foreign`;') - await queryFn('ALTER TABLE `communities` DROP COLUMN `verified_at`;') - await queryFn('ALTER TABLE `communities` DROP COLUMN `last_error_at`;') + await queryFn( + 'ALTER TABLE `events` MODIFY COLUMN `message_id` int(10) unsigned DEFAULT NULL AFTER `amount`;', + ) + await queryFn( + 'ALTER TABLE `events` RENAME COLUMN `involved_contribution_id` TO `contribution_id`;', + ) + await queryFn('ALTER TABLE `events` RENAME COLUMN `involved_transaction_id` TO `transaction_id`;') + await queryFn( + 'ALTER TABLE `events` ADD COLUMN `x_community_id` int(10) unsigned DEFAULT NULL AFTER `involved_user_id`;', + ) + await queryFn('ALTER TABLE `events` RENAME COLUMN `involved_user_id` TO `x_user_id`;') + await queryFn('ALTER TABLE `events` DROP COLUMN `acting_user_id`;') + await queryFn('ALTER TABLE `events` RENAME COLUMN `affected_user_id` TO `user_id`;') + await queryFn('RENAME TABLE `events` TO `event_protocol`;') } From 5aef000520129810dbf5b2e2964c6e970762ac11 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 17 Feb 2023 14:53:07 +0100 Subject: [PATCH 018/373] lint fixes --- database/entity/0061-event_refactoring/Event.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/database/entity/0061-event_refactoring/Event.ts b/database/entity/0061-event_refactoring/Event.ts index 80b4238bb..5a62fcdc2 100644 --- a/database/entity/0061-event_refactoring/Event.ts +++ b/database/entity/0061-event_refactoring/Event.ts @@ -3,7 +3,15 @@ import { ContributionMessage } from '../ContributionMessage' import { User } from '../User' import { Transaction } from '../Transaction' import Decimal from 'decimal.js-light' -import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, ManyToOne, JoinColumn } from 'typeorm' +import { + BaseEntity, + Entity, + PrimaryGeneratedColumn, + Column, + CreateDateColumn, + ManyToOne, + JoinColumn, +} from 'typeorm' import { DecimalTransformer } from '../../src/typeorm/DecimalTransformer' @Entity('events') @@ -14,7 +22,12 @@ export class Event extends BaseEntity { @Column({ length: 100, nullable: false, collation: 'utf8mb4_unicode_ci' }) type: string - @CreateDateColumn({ name: 'created_at', type: 'datetime', default: () => 'CURRENT_TIMESTAMP()' , nullable: false }) + @CreateDateColumn({ + name: 'created_at', + type: 'datetime', + default: () => 'CURRENT_TIMESTAMP()', + nullable: false, + }) createdAt: Date // @Column({ name: 'affected_user_id', unsigned: true, nullable: false }) From d8f2843a55c8079e6268981f03b0229af6c24025 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 18 Feb 2023 00:11:29 +0100 Subject: [PATCH 019/373] fix database version requirement of dht-node & federation --- dht-node/src/config/index.ts | 2 +- federation/src/config/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dht-node/src/config/index.ts b/dht-node/src/config/index.ts index 8210ddfcc..6ba9493ac 100644 --- a/dht-node/src/config/index.ts +++ b/dht-node/src/config/index.ts @@ -3,7 +3,7 @@ import dotenv from 'dotenv' dotenv.config() const constants = { - DB_VERSION: '0060-update_communities_table', + DB_VERSION: '0061-event_refactoring', LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info LOG_LEVEL: process.env.LOG_LEVEL || 'info', diff --git a/federation/src/config/index.ts b/federation/src/config/index.ts index c8a841315..6b3bf6424 100644 --- a/federation/src/config/index.ts +++ b/federation/src/config/index.ts @@ -11,7 +11,7 @@ Decimal.set({ */ const constants = { - DB_VERSION: '0060-update_communities_table', + DB_VERSION: '0060-0061-event_refactoring', // DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0 LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info From fde67c2c32b61e4cfaec449f641d331aa6410a3f Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 18 Feb 2023 00:12:36 +0100 Subject: [PATCH 020/373] todo event data refactoring --- database/migrations/0061-event_refactoring.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/database/migrations/0061-event_refactoring.ts b/database/migrations/0061-event_refactoring.ts index 88874b15e..2fdc7dcef 100644 --- a/database/migrations/0061-event_refactoring.ts +++ b/database/migrations/0061-event_refactoring.ts @@ -31,6 +31,8 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis await queryFn( 'ALTER TABLE `events` RENAME COLUMN `message_id` TO `involved_contribution_message_id`;', ) + + // TODO insert data based on event type } export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { From 41569ad0f11b91ff8299dde0a255b0c3af2876b7 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 18 Feb 2023 01:08:06 +0100 Subject: [PATCH 021/373] refactor events - first step to get backend working --- backend/src/config/index.ts | 2 +- backend/src/event/Event.ts | 192 ++++++++++-------- .../resolver/ContributionResolver.test.ts | 22 +- .../graphql/resolver/ContributionResolver.ts | 31 ++- .../resolver/TransactionResolver.test.ts | 6 +- .../graphql/resolver/TransactionResolver.ts | 13 +- .../src/graphql/resolver/UserResolver.test.ts | 20 +- backend/src/graphql/resolver/UserResolver.ts | 35 +++- 8 files changed, 182 insertions(+), 139 deletions(-) diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 27b51b47d..961d83219 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0060-update_communities_table', + DB_VERSION: '0061-event_refactoring', DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0 LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info diff --git a/backend/src/event/Event.ts b/backend/src/event/Event.ts index 8e65d85f2..5ba21fe19 100644 --- a/backend/src/event/Event.ts +++ b/backend/src/event/Event.ts @@ -1,212 +1,230 @@ -import { EventProtocol as DbEvent } from '@entity/EventProtocol' +import { Event as DbEvent } from '@entity/Event' +import { User as DbUser } from '@entity/User' +import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' +import { Contribution as DbContribution } from '@entity/Contribution' +import { Transaction as DbTransaction } from '@entity/Transaction' import Decimal from 'decimal.js-light' import { EventProtocolType } from './EventProtocolType' export const Event = ( type: EventProtocolType, - userId: number, - xUserId: number | null = null, - xCommunityId: number | null = null, - transactionId: number | null = null, - contributionId: number | null = null, + affectedUser: DbUser, + actingUser: DbUser, + involvedUser: DbUser | null = null, + involvedTransaction: DbTransaction | null = null, + involvedContribution: DbContribution | null = null, + involvedContributionMessage: DbContributionMessage | null = null, amount: Decimal | null = null, - messageId: number | null = null, ): DbEvent => { const event = new DbEvent() event.type = type - event.userId = userId - event.xUserId = xUserId - event.xCommunityId = xCommunityId - event.transactionId = transactionId - event.contributionId = contributionId + event.affectedUser = affectedUser + event.actingUser = actingUser + event.involvedUser = involvedUser + event.involvedTransaction = involvedTransaction + event.involvedContribution = involvedContribution + event.involvedContributionMessage = involvedContributionMessage event.amount = amount - event.messageId = messageId return event } export const EVENT_CONTRIBUTION_CREATE = async ( - userId: number, - contributionId: number, + user: DbUser, + contribution: DbContribution, amount: Decimal, ): Promise => Event( EventProtocolType.CONTRIBUTION_CREATE, - userId, + user, + user, null, null, + contribution, null, - contributionId, amount, ).save() export const EVENT_CONTRIBUTION_DELETE = async ( - userId: number, - contributionId: number, + user: DbUser, + contribution: DbContribution, amount: Decimal, ): Promise => Event( EventProtocolType.CONTRIBUTION_DELETE, - userId, + user, + user, null, null, + contribution, null, - contributionId, amount, ).save() export const EVENT_CONTRIBUTION_UPDATE = async ( - userId: number, - contributionId: number, + user: DbUser, + contribution: DbContribution, amount: Decimal, ): Promise => Event( EventProtocolType.CONTRIBUTION_UPDATE, - userId, + user, + user, null, null, + contribution, null, - contributionId, amount, ).save() +// TODO what was user_id? affected or moderator user? +// await EVENT_ADMIN_CONTRIBUTION_CREATE(moderator.id, contribution.id, amount) export const EVENT_ADMIN_CONTRIBUTION_CREATE = async ( - userId: number, - contributionId: number, + user: DbUser, + moderator: DbUser, + contribution: DbContribution, amount: Decimal, ): Promise => Event( EventProtocolType.ADMIN_CONTRIBUTION_CREATE, - userId, + user, + moderator, null, null, + contribution, null, - contributionId, amount, ).save() +// TODO await EVENT_ADMIN_CONTRIBUTION_UPDATE(emailContact.user.id, contributionToUpdate.id, amount) export const EVENT_ADMIN_CONTRIBUTION_UPDATE = async ( - userId: number, - contributionId: number, + user: DbUser, + moderator: DbUser, + contribution: DbContribution, amount: Decimal, ): Promise => Event( EventProtocolType.ADMIN_CONTRIBUTION_UPDATE, - userId, + user, + moderator, null, null, + contribution, null, - contributionId, amount, ).save() +// TODO await EVENT_ADMIN_CONTRIBUTION_DELETE(contribution.userId, contribution.id, contribution.amount) export const EVENT_ADMIN_CONTRIBUTION_DELETE = async ( - userId: number, - contributionId: number, + user: DbUser, + moderator: DbUser, + contribution: DbContribution, amount: Decimal, ): Promise => Event( EventProtocolType.ADMIN_CONTRIBUTION_DELETE, - userId, + user, + moderator, null, null, + contribution, null, - contributionId, amount, ).save() +// TODO await EVENT_CONTRIBUTION_CONFIRM(user.id, contribution.id, contribution.amount) export const EVENT_CONTRIBUTION_CONFIRM = async ( - userId: number, - contributionId: number, + user: DbUser, + moderator: DbUser, + contribution: DbContribution, amount: Decimal, ): Promise => Event( EventProtocolType.CONTRIBUTION_CONFIRM, - userId, + user, + moderator, null, null, + contribution, null, - contributionId, amount, ).save() +// TODO await EVENT_ADMIN_CONTRIBUTION_DENY( +// contributionToUpdate.userId, +// moderator.id, +// contributionToUpdate.id, +// contributionToUpdate.amount, +// ) +// x User = moderator export const EVENT_ADMIN_CONTRIBUTION_DENY = async ( - userId: number, - xUserId: number, - contributionId: number, + user: DbUser, + moderator: DbUser, + contribution: DbContribution, amount: Decimal, ): Promise => Event( EventProtocolType.ADMIN_CONTRIBUTION_DENY, - userId, - xUserId, + user, + moderator, null, null, - contributionId, + contribution, + null, amount, ).save() export const EVENT_TRANSACTION_SEND = async ( - userId: number, - xUserId: number, - transactionId: number, + user: DbUser, + involvedUser: DbUser, + transaction: DbTransaction, amount: Decimal, ): Promise => Event( EventProtocolType.TRANSACTION_SEND, - userId, - xUserId, + user, + user, + involvedUser, + transaction, null, - transactionId, null, amount, ).save() +// TODO acting user = involved user export const EVENT_TRANSACTION_RECEIVE = async ( - userId: number, - xUserId: number, - transactionId: number, + user: DbUser, + involvedUser: DbUser, + transaction: DbTransaction, amount: Decimal, ): Promise => Event( EventProtocolType.TRANSACTION_RECEIVE, - userId, - xUserId, + user, + involvedUser, + involvedUser, + transaction, null, - transactionId, null, amount, ).save() -export const EVENT_LOGIN = async (userId: number): Promise => - Event(EventProtocolType.LOGIN, userId, null, null, null, null, null, null).save() +export const EVENT_LOGIN = async (user: DbUser): Promise => + Event(EventProtocolType.LOGIN, user, user).save() -export const EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL = async ( - userId: number, -): Promise => Event(EventProtocolType.SEND_ACCOUNT_MULTIREGISTRATION_EMAIL, userId).save() +export const EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL = async (user: DbUser): Promise => + Event(EventProtocolType.SEND_ACCOUNT_MULTIREGISTRATION_EMAIL, user, { id: 0 } as DbUser).save() -export const EVENT_SEND_CONFIRMATION_EMAIL = async (userId: number): Promise => - Event(EventProtocolType.SEND_CONFIRMATION_EMAIL, userId).save() +export const EVENT_SEND_CONFIRMATION_EMAIL = async (user: DbUser): Promise => + Event(EventProtocolType.SEND_CONFIRMATION_EMAIL, user, user).save() -export const EVENT_ADMIN_SEND_CONFIRMATION_EMAIL = async (userId: number): Promise => - Event(EventProtocolType.ADMIN_SEND_CONFIRMATION_EMAIL, userId).save() +export const EVENT_ADMIN_SEND_CONFIRMATION_EMAIL = async ( + user: DbUser, + moderator: DbUser, +): Promise => + Event(EventProtocolType.ADMIN_SEND_CONFIRMATION_EMAIL, user, moderator).save() -/* export const EVENT_REDEEM_REGISTER = async ( - userId: number, - transactionId: number | null = null, - contributionId: number | null = null, -): Promise => - Event( - EventProtocolType.REDEEM_REGISTER, - userId, - null, - null, - transactionId, - contributionId, - ).save() -*/ +export const EVENT_REGISTER = async (user: DbUser): Promise => + Event(EventProtocolType.REGISTER, user, user).save() -export const EVENT_REGISTER = async (userId: number): Promise => - Event(EventProtocolType.REGISTER, userId).save() - -export const EVENT_ACTIVATE_ACCOUNT = async (userId: number): Promise => - Event(EventProtocolType.ACTIVATE_ACCOUNT, userId).save() +export const EVENT_ACTIVATE_ACCOUNT = async (user: DbUser): Promise => + Event(EventProtocolType.ACTIVATE_ACCOUNT, user, user).save() diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index b56180c45..8f2ae3981 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -38,7 +38,7 @@ import { userFactory } from '@/seeds/factory/user' import { creationFactory } from '@/seeds/factory/creation' import { creations } from '@/seeds/creation/index' import { peterLustig } from '@/seeds/users/peter-lustig' -import { EventProtocol } from '@entity/EventProtocol' +import { Event as DbEvent } from '@entity/Event' import { Contribution } from '@entity/Contribution' import { Transaction as DbTransaction } from '@entity/Transaction' import { User } from '@entity/User' @@ -284,7 +284,7 @@ describe('ContributionResolver', () => { }) it('stores the CONTRIBUTION_CREATE event in the database', async () => { - await expect(EventProtocol.find()).resolves.toContainEqual( + await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.CONTRIBUTION_CREATE, amount: expect.decimalEqual(100), @@ -589,7 +589,7 @@ describe('ContributionResolver', () => { variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' }, }) - await expect(EventProtocol.find()).resolves.toContainEqual( + await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.CONTRIBUTION_UPDATE, amount: expect.decimalEqual(10), @@ -819,7 +819,7 @@ describe('ContributionResolver', () => { }) it('stores the ADMIN_CONTRIBUTION_DENY event in the database', async () => { - await expect(EventProtocol.find()).resolves.toContainEqual( + await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.ADMIN_CONTRIBUTION_DENY, userId: bibi.id, @@ -934,7 +934,7 @@ describe('ContributionResolver', () => { }) it('stores the CONTRIBUTION_DELETE event in the database', async () => { - await expect(EventProtocol.find()).resolves.toContainEqual( + await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.CONTRIBUTION_DELETE, contributionId: contributionToDelete.data.createContribution.id, @@ -2082,7 +2082,7 @@ describe('ContributionResolver', () => { }) it('stores the ADMIN_CONTRIBUTION_CREATE event in the database', async () => { - await expect(EventProtocol.find()).resolves.toContainEqual( + await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.ADMIN_CONTRIBUTION_CREATE, userId: admin.id, @@ -2353,7 +2353,7 @@ describe('ContributionResolver', () => { }) it('stores the ADMIN_CONTRIBUTION_UPDATE event in the database', async () => { - await expect(EventProtocol.find()).resolves.toContainEqual( + await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.ADMIN_CONTRIBUTION_UPDATE, userId: admin.id, @@ -2394,7 +2394,7 @@ describe('ContributionResolver', () => { }) it('stores the ADMIN_CONTRIBUTION_UPDATE event in the database', async () => { - await expect(EventProtocol.find()).resolves.toContainEqual( + await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.ADMIN_CONTRIBUTION_UPDATE, userId: admin.id, @@ -2573,7 +2573,7 @@ describe('ContributionResolver', () => { }) it('stores the ADMIN_CONTRIBUTION_DELETE event in the database', async () => { - await expect(EventProtocol.find()).resolves.toContainEqual( + await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.ADMIN_CONTRIBUTION_DELETE, userId: admin.id, @@ -2717,7 +2717,7 @@ describe('ContributionResolver', () => { }) it('stores the CONTRIBUTION_CONFIRM event in the database', async () => { - await expect(EventProtocol.find()).resolves.toContainEqual( + await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.CONTRIBUTION_CONFIRM, }), @@ -2749,7 +2749,7 @@ describe('ContributionResolver', () => { }) it('stores the SEND_CONFIRMATION_EMAIL event in the database', async () => { - await expect(EventProtocol.find()).resolves.toContainEqual( + await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.SEND_CONFIRMATION_EMAIL, }), diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index c2f0d7d23..145966f47 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -91,7 +91,7 @@ export class ContributionResolver { logger.trace('contribution to save', contribution) await DbContribution.save(contribution) - await EVENT_CONTRIBUTION_CREATE(user.id, contribution.id, amount) + await EVENT_CONTRIBUTION_CREATE(user, contribution, amount) return new UnconfirmedContribution(contribution, user, creations) } @@ -119,7 +119,7 @@ export class ContributionResolver { contribution.deletedAt = new Date() await contribution.save() - await EVENT_CONTRIBUTION_DELETE(user.id, contribution.id, contribution.amount) + await EVENT_CONTRIBUTION_DELETE(user, contribution, contribution.amount) const res = await contribution.softRemove() return !!res @@ -267,7 +267,7 @@ export class ContributionResolver { contributionToUpdate.updatedAt = new Date() DbContribution.save(contributionToUpdate) - await EVENT_CONTRIBUTION_UPDATE(user.id, contributionId, amount) + await EVENT_CONTRIBUTION_UPDATE(user, contributionToUpdate, amount) return new UnconfirmedContribution(contributionToUpdate, user, creations) } @@ -324,7 +324,7 @@ export class ContributionResolver { await DbContribution.save(contribution) - await EVENT_ADMIN_CONTRIBUTION_CREATE(moderator.id, contribution.id, amount) + await EVENT_ADMIN_CONTRIBUTION_CREATE(emailContact.user, moderator, contribution, amount) return getUserCreation(emailContact.userId, clientTimezoneOffset) } @@ -419,7 +419,12 @@ export class ContributionResolver { result.creation = await getUserCreation(emailContact.user.id, clientTimezoneOffset) - await EVENT_ADMIN_CONTRIBUTION_UPDATE(emailContact.user.id, contributionToUpdate.id, amount) + await EVENT_ADMIN_CONTRIBUTION_UPDATE( + emailContact.user, + moderator, + contributionToUpdate, + amount, + ) return result } @@ -490,7 +495,13 @@ export class ContributionResolver { await contribution.save() const res = await contribution.softRemove() - await EVENT_ADMIN_CONTRIBUTION_DELETE(contribution.userId, contribution.id, contribution.amount) + // TODO allow to query the user with relation + await EVENT_ADMIN_CONTRIBUTION_DELETE( + { id: contribution.userId } as DbUser, + moderator, + contribution, + contribution.amount, + ) sendContributionDeletedEmail({ firstName: user.firstName, @@ -603,7 +614,7 @@ export class ContributionResolver { await queryRunner.release() } - await EVENT_CONTRIBUTION_CONFIRM(user.id, contribution.id, contribution.amount) + await EVENT_CONTRIBUTION_CONFIRM(user, moderatorUser, contribution, contribution.amount) } finally { releaseLock() } @@ -694,9 +705,9 @@ export class ContributionResolver { const res = await contributionToUpdate.save() await EVENT_ADMIN_CONTRIBUTION_DENY( - contributionToUpdate.userId, - moderator.id, - contributionToUpdate.id, + user, + moderator, + contributionToUpdate, contributionToUpdate.amount, ) diff --git a/backend/src/graphql/resolver/TransactionResolver.test.ts b/backend/src/graphql/resolver/TransactionResolver.test.ts index 6751aa6ad..fd4f839b6 100644 --- a/backend/src/graphql/resolver/TransactionResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionResolver.test.ts @@ -14,7 +14,7 @@ import { bobBaumeister } from '@/seeds/users/bob-baumeister' import { garrickOllivander } from '@/seeds/users/garrick-ollivander' import { peterLustig } from '@/seeds/users/peter-lustig' import { stephenHawking } from '@/seeds/users/stephen-hawking' -import { EventProtocol } from '@entity/EventProtocol' +import { Event as DbEvent } from '@entity/Event' import { Transaction } from '@entity/Transaction' import { User } from '@entity/User' import { cleanDB, testEnvironment } from '@test/helpers' @@ -337,7 +337,7 @@ describe('send coins', () => { memo: 'unrepeatable memo', }) - expect(EventProtocol.find()).resolves.toContainEqual( + expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.TRANSACTION_SEND, userId: user[1].id, @@ -354,7 +354,7 @@ describe('send coins', () => { memo: 'unrepeatable memo', }) - expect(EventProtocol.find()).resolves.toContainEqual( + expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.TRANSACTION_RECEIVE, userId: user[0].id, diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index 9d5a1d38c..f0527ee61 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -138,16 +138,17 @@ export const executeTransaction = async ( logger.info(`commit Transaction successful...`) await EVENT_TRANSACTION_SEND( - transactionSend.userId, - transactionSend.linkedUserId, - transactionSend.id, + sender, + recipient, + transactionSend, + // TODO why mul -1? transactionSend.amount.mul(-1), ) await EVENT_TRANSACTION_RECEIVE( - transactionReceive.userId, - transactionReceive.linkedUserId, - transactionReceive.id, + recipient, + sender, + transactionReceive, transactionReceive.amount, ) } catch (e) { diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index 19eb04b34..a2dd08ea4 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -35,7 +35,7 @@ import { transactionLinkFactory } from '@/seeds/factory/transactionLink' import { ContributionLink } from '@model/ContributionLink' import { TransactionLink } from '@entity/TransactionLink' import { EventProtocolType } from '@/event/EventProtocolType' -import { EventProtocol } from '@entity/EventProtocol' +import { Event as DbEvent } from '@entity/Event' import { validate as validateUUID, version as versionUUID } from 'uuid' import { peterLustig } from '@/seeds/users/peter-lustig' import { UserContact } from '@entity/UserContact' @@ -182,7 +182,7 @@ describe('UserResolver', () => { { email: 'peter@lustig.de' }, { relations: ['user'] }, ) - expect(EventProtocol.find()).resolves.toContainEqual( + expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.REGISTER, userId: userConatct.user.id, @@ -211,7 +211,7 @@ describe('UserResolver', () => { }) it('stores the SEND_CONFIRMATION_EMAIL event in the database', () => { - expect(EventProtocol.find()).resolves.toContainEqual( + expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.SEND_CONFIRMATION_EMAIL, userId: user[0].id, @@ -256,7 +256,7 @@ describe('UserResolver', () => { { email: 'peter@lustig.de' }, { relations: ['user'] }, ) - expect(EventProtocol.find()).resolves.toContainEqual( + expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.SEND_ACCOUNT_MULTIREGISTRATION_EMAIL, userId: userConatct.user.id, @@ -356,7 +356,7 @@ describe('UserResolver', () => { }) it('stores the ACTIVATE_ACCOUNT event in the database', () => { - expect(EventProtocol.find()).resolves.toContainEqual( + expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.ACTIVATE_ACCOUNT, userId: user[0].id, @@ -365,7 +365,7 @@ describe('UserResolver', () => { }) it('stores the REDEEM_REGISTER event in the database', () => { - expect(EventProtocol.find()).resolves.toContainEqual( + expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.REDEEM_REGISTER, userId: result.data.createUser.id, @@ -449,7 +449,7 @@ describe('UserResolver', () => { }) it('stores the REDEEM_REGISTER event in the database', async () => { - await expect(EventProtocol.find()).resolves.toContainEqual( + await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.REDEEM_REGISTER, userId: newUser.data.createUser.id, @@ -680,7 +680,7 @@ describe('UserResolver', () => { { email: 'bibi@bloxberg.de' }, { relations: ['user'] }, ) - expect(EventProtocol.find()).resolves.toContainEqual( + expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.LOGIN, userId: userConatct.user.id, @@ -928,7 +928,7 @@ describe('UserResolver', () => { }) it('stores the LOGIN event in the database', () => { - expect(EventProtocol.find()).resolves.toContainEqual( + expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.LOGIN, userId: user[0].id, @@ -1847,7 +1847,7 @@ describe('UserResolver', () => { { email: 'bibi@bloxberg.de' }, { relations: ['user'] }, ) - expect(EventProtocol.find()).resolves.toContainEqual( + expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.ADMIN_SEND_CONFIRMATION_EMAIL, userId: userConatct.user.id, diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index f9617b0df..435ca3c82 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -16,7 +16,9 @@ import { getConnection, getCustomRepository, IsNull, Not } from '@dbTools/typeor import { User as DbUser } from '@entity/User' import { UserContact as DbUserContact } from '@entity/UserContact' import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' +import { Transaction as DbTransaction } from '@entity/Transaction' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' +import { Contribution as DbContribution } from '@entity/Contribution' import { UserRepository } from '@repository/User' import { User } from '@model/User' @@ -178,7 +180,7 @@ export class UserResolver { value: encode(dbUser.gradidoID), }) - await EVENT_LOGIN(user.id) + await EVENT_LOGIN(dbUser) logger.info(`successful Login: ${JSON.stringify(user, null, 2)}`) return user } @@ -248,7 +250,7 @@ export class UserResolver { language: foundUser.language, // use language of the emails owner for sending }) - await EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL(foundUser.id) + await EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL(foundUser) logger.info( `sendAccountMultiRegistrationEmail by ${firstName} ${lastName} to ${foundUser.firstName} ${foundUser.lastName} <${email}>`, @@ -266,7 +268,11 @@ export class UserResolver { const gradidoID = await newGradidoID() - const eventRegisterRedeem = Event(EventProtocolType.REDEEM_REGISTER, 0) + const eventRegisterRedeem = Event( + EventProtocolType.REDEEM_REGISTER, + { id: 0 } as DbUser, + { id: 0 } as DbUser, + ) let dbUser = new DbUser() dbUser.gradidoID = gradidoID dbUser.firstName = firstName @@ -283,14 +289,16 @@ export class UserResolver { logger.info('redeemCode found contributionLink=' + contributionLink) if (contributionLink) { dbUser.contributionLinkId = contributionLink.id - eventRegisterRedeem.contributionId = contributionLink.id + // TODO this is so wrong + eventRegisterRedeem.involvedContribution = { id: contributionLink.id } as DbContribution } } else { const transactionLink = await DbTransactionLink.findOne({ code: redeemCode }) logger.info('redeemCode found transactionLink=' + transactionLink) if (transactionLink) { dbUser.referrerId = transactionLink.userId - eventRegisterRedeem.transactionId = transactionLink.id + // TODO this is so wrong + eventRegisterRedeem.involvedTransaction = { id: transactionLink.id } as DbTransaction } } } @@ -329,7 +337,7 @@ export class UserResolver { }) logger.info(`sendAccountActivationEmail of ${firstName}.${lastName} to ${email}`) - await EVENT_SEND_CONFIRMATION_EMAIL(dbUser.id) + await EVENT_SEND_CONFIRMATION_EMAIL(dbUser) if (!emailSent) { logger.debug(`Account confirmation link: ${activationLink}`) @@ -346,10 +354,11 @@ export class UserResolver { logger.info('createUser() successful...') if (redeemCode) { - eventRegisterRedeem.userId = dbUser.id + eventRegisterRedeem.affectedUser = dbUser + eventRegisterRedeem.actingUser = dbUser await eventRegisterRedeem.save() } else { - await EVENT_REGISTER(dbUser.id) + await EVENT_REGISTER(dbUser) } return new User(dbUser) @@ -465,7 +474,7 @@ export class UserResolver { await queryRunner.commitTransaction() logger.info('User and UserContact data written successfully...') - await EVENT_ACTIVATE_ACCOUNT(user.id) + await EVENT_ACTIVATE_ACCOUNT(user) } catch (e) { await queryRunner.rollbackTransaction() throw new LogError('Error on writing User and User Contact data', e) @@ -775,9 +784,13 @@ export class UserResolver { return null } + // TODO this is an admin function - needs refactor @Authorized([RIGHTS.SEND_ACTIVATION_EMAIL]) @Mutation(() => Boolean) - async sendActivationEmail(@Arg('email') email: string): Promise { + async sendActivationEmail( + @Arg('email') email: string, + @Ctx() context: Context, + ): Promise { email = email.trim().toLowerCase() // const user = await dbUser.findOne({ id: emailContact.userId }) const user = await findUserByEmail(email) @@ -802,7 +815,7 @@ export class UserResolver { if (!emailSent) { logger.info(`Account confirmation link: ${activationLink}`) } else { - await EVENT_ADMIN_SEND_CONFIRMATION_EMAIL(user.id) + await EVENT_ADMIN_SEND_CONFIRMATION_EMAIL(user, getUser(context)) } return true From 4e55acebeb0fec2e92a010b109a307e4b26fddd3 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 18 Feb 2023 01:24:48 +0100 Subject: [PATCH 022/373] have explicit reference id columns due to missing foreign keys --- .../entity/0061-event_refactoring/Event.ts | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/database/entity/0061-event_refactoring/Event.ts b/database/entity/0061-event_refactoring/Event.ts index 5a62fcdc2..219861834 100644 --- a/database/entity/0061-event_refactoring/Event.ts +++ b/database/entity/0061-event_refactoring/Event.ts @@ -30,45 +30,46 @@ export class Event extends BaseEntity { }) createdAt: Date - // @Column({ name: 'affected_user_id', unsigned: true, nullable: false }) - // affectedUserId: number + @Column({ name: 'affected_user_id', unsigned: true, nullable: false }) + affectedUserId: number @ManyToOne(() => User) @JoinColumn({ name: 'affected_user_id', referencedColumnName: 'id' }) affectedUser: User // TODO potentially save actingRole as well - // @Column({ name: 'acting_user_id', unsigned: true, nullable: false }) - // actingUserId: number + @Column({ name: 'acting_user_id', unsigned: true, nullable: false }) + actingUserId: number @ManyToOne(() => User) @JoinColumn({ name: 'acting_user_id', referencedColumnName: 'id' }) actingUser: User - // @Column({ name: 'involved_user_id', type: 'int', unsigned: true, nullable: true }) - // involvedUserId: number | null + @Column({ name: 'involved_user_id', type: 'int', unsigned: true, nullable: true }) + involvedUserId: number | null @ManyToOne(() => User) @JoinColumn({ name: 'involved_user_id', referencedColumnName: 'id' }) involvedUser: User | null - // @Column({ name: 'involved_transaction_id', type: 'int', unsigned: true, nullable: true }) - // involvedTransactionId: number | null + @Column({ name: 'involved_transaction_id', type: 'int', unsigned: true, nullable: true }) + involvedTransactionId: number | null @ManyToOne(() => Transaction) @JoinColumn({ name: 'involved_transaction_id', referencedColumnName: 'id' }) involvedTransaction: Transaction | null - // @Column({ name: 'involved_contribution_id', type: 'int', unsigned: true, nullable: true }) - // involvedContributionId: number | null + @Column({ name: 'involved_contribution_id', type: 'int', unsigned: true, nullable: true }) + involvedContributionId: number | null @ManyToOne(() => Contribution) @JoinColumn({ name: 'involved_contribution_id', referencedColumnName: 'id' }) involvedContribution: Contribution | null // TEST do we need the Id field definition? - // @Column({ name: 'involved_contribution_message_id', type: 'int', unsigned: true, nullable: true }) - // involvedContributionMessageId: number | null + // TODO we need proper foreign keys to have things working without the explicit column + @Column({ name: 'involved_contribution_message_id', type: 'int', unsigned: true, nullable: true }) + involvedContributionMessageId: number | null @ManyToOne(() => ContributionMessage) @JoinColumn({ name: 'involved_contribution_message_id', referencedColumnName: 'id' }) From e73c26a1cd045a28c55c9954e63e8346dcc4b983 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 18 Feb 2023 01:31:29 +0100 Subject: [PATCH 023/373] fix transactionResolver tests --- .../graphql/resolver/TransactionResolver.test.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/backend/src/graphql/resolver/TransactionResolver.test.ts b/backend/src/graphql/resolver/TransactionResolver.test.ts index fd4f839b6..6ddbb8191 100644 --- a/backend/src/graphql/resolver/TransactionResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionResolver.test.ts @@ -340,9 +340,10 @@ describe('send coins', () => { expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.TRANSACTION_SEND, - userId: user[1].id, - transactionId: transaction[0].id, - xUserId: user[0].id, + affectedUserId: user[1].id, + actingUserId: user[1].id, + involvedUserId: user[0].id, + involvedTransactionId: transaction[0].id, }), ) }) @@ -357,9 +358,10 @@ describe('send coins', () => { expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.TRANSACTION_RECEIVE, - userId: user[0].id, - transactionId: transaction[0].id, - xUserId: user[1].id, + affectedUserId: user[0].id, + actingUserId: user[1].id, + involvedUserId: user[1].id, + involvedTransactionId: transaction[0].id, }), ) }) From 08ad0fb1bbe457a6e97836cfa9ead0d9e746af27 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 18 Feb 2023 01:43:27 +0100 Subject: [PATCH 024/373] fix userResolver tests --- .../src/graphql/resolver/UserResolver.test.ts | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index a2dd08ea4..e627f4f0f 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -185,7 +185,8 @@ describe('UserResolver', () => { expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.REGISTER, - userId: userConatct.user.id, + affectedUserId: userConatct.user.id, + actingUserId: userConatct.user.id, }), ) }) @@ -214,7 +215,8 @@ describe('UserResolver', () => { expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.SEND_CONFIRMATION_EMAIL, - userId: user[0].id, + affectedUserId: user[0].id, + actingUserId: user[0].id, }), ) }) @@ -259,7 +261,8 @@ describe('UserResolver', () => { expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.SEND_ACCOUNT_MULTIREGISTRATION_EMAIL, - userId: userConatct.user.id, + affectedUserId: userConatct.user.id, + actingUserId: 0, }), ) }) @@ -359,7 +362,8 @@ describe('UserResolver', () => { expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.ACTIVATE_ACCOUNT, - userId: user[0].id, + affectedUserId: user[0].id, + actingUserId: user[0].id, }), ) }) @@ -368,8 +372,9 @@ describe('UserResolver', () => { expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.REDEEM_REGISTER, - userId: result.data.createUser.id, - contributionId: link.id, + affectedUserId: result.data.createUser.id, + actingUserId: result.data.createUser.id, + involvedContributionId: link.id, }), ) }) @@ -452,7 +457,9 @@ describe('UserResolver', () => { await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.REDEEM_REGISTER, - userId: newUser.data.createUser.id, + affectedUserId: newUser.data.createUser.id, + actingUserId: newUser.data.createUser.id, + involvedTransactionId: transactionLink.id, }), ) }) @@ -683,7 +690,8 @@ describe('UserResolver', () => { expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.LOGIN, - userId: userConatct.user.id, + affectedUserId: userConatct.user.id, + actingUserId: userConatct.user.id, }), ) }) @@ -931,7 +939,8 @@ describe('UserResolver', () => { expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.LOGIN, - userId: user[0].id, + affectedUserId: user[0].id, + actingUserId: user[0].id, }), ) }) @@ -1850,7 +1859,8 @@ describe('UserResolver', () => { expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.ADMIN_SEND_CONFIRMATION_EMAIL, - userId: userConatct.user.id, + affectedUserId: userConatct.user.id, + actingUserId: admin.id, }), ) }) From 8744ff919e21bcdd4757453a71c6db9e23e2af03 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 18 Feb 2023 02:01:31 +0100 Subject: [PATCH 025/373] fix contributionResolver tests --- .../resolver/ContributionResolver.test.ts | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 8f2ae3981..540285c53 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -287,9 +287,10 @@ describe('ContributionResolver', () => { await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.CONTRIBUTION_CREATE, + affectedUserId: bibi.id, + actingUserId: bibi.id, + involvedContributionId: pendingContribution.data.createContribution.id, amount: expect.decimalEqual(100), - contributionId: pendingContribution.data.createContribution.id, - userId: bibi.id, }), ) }) @@ -592,9 +593,10 @@ describe('ContributionResolver', () => { await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.CONTRIBUTION_UPDATE, + affectedUserId: bibi.id, + actingUserId: bibi.id, + involvedContributionId: pendingContribution.data.createContribution.id, amount: expect.decimalEqual(10), - contributionId: pendingContribution.data.createContribution.id, - userId: bibi.id, }), ) }) @@ -822,9 +824,9 @@ describe('ContributionResolver', () => { await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.ADMIN_CONTRIBUTION_DENY, - userId: bibi.id, - xUserId: admin.id, - contributionId: contributionToDeny.data.createContribution.id, + affectedUserId: bibi.id, + actingUserId: admin.id, + involvedContributionId: contributionToDeny.data.createContribution.id, amount: expect.decimalEqual(100), }), ) @@ -937,9 +939,10 @@ describe('ContributionResolver', () => { await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.CONTRIBUTION_DELETE, - contributionId: contributionToDelete.data.createContribution.id, + affectedUserId: bibi.id, + actingUserId: bibi.id, + involvedContributionId: contributionToDelete.data.createContribution.id, amount: expect.decimalEqual(100), - userId: bibi.id, }), ) }) @@ -2085,7 +2088,8 @@ describe('ContributionResolver', () => { await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.ADMIN_CONTRIBUTION_CREATE, - userId: admin.id, + affectedUserId: bibi.id, + actingUserId: admin.id, amount: expect.decimalEqual(200), }), ) @@ -2329,7 +2333,7 @@ describe('ContributionResolver', () => { mutate({ mutation: adminUpdateContribution, variables: { - id: creation ? creation.id : -1, + id: creation?.id, email: 'peter@lustig.de', amount: new Decimal(300), memo: 'Danke Peter!', @@ -2356,7 +2360,8 @@ describe('ContributionResolver', () => { await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.ADMIN_CONTRIBUTION_UPDATE, - userId: admin.id, + affectedUserId: creation?.userId, + actingUserId: admin.id, amount: 300, }), ) @@ -2370,7 +2375,7 @@ describe('ContributionResolver', () => { mutate({ mutation: adminUpdateContribution, variables: { - id: creation ? creation.id : -1, + id: creation?.id, email: 'peter@lustig.de', amount: new Decimal(200), memo: 'Das war leider zu Viel!', @@ -2397,7 +2402,8 @@ describe('ContributionResolver', () => { await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.ADMIN_CONTRIBUTION_UPDATE, - userId: admin.id, + affectedUserId: creation?.userId, + actingUserId: admin.id, amount: expect.decimalEqual(200), }), ) @@ -2562,7 +2568,7 @@ describe('ContributionResolver', () => { mutate({ mutation: adminDeleteContribution, variables: { - id: creation ? creation.id : -1, + id: creation?.id, }, }), ).resolves.toEqual( @@ -2576,7 +2582,9 @@ describe('ContributionResolver', () => { await expect(DbEvent.find()).resolves.toContainEqual( expect.objectContaining({ type: EventProtocolType.ADMIN_CONTRIBUTION_DELETE, - userId: admin.id, + affectedUserId: creation?.userId, + actingUserId: admin.id, + involvedContributionId: creation?.id, amount: expect.decimalEqual(200), }), ) From 89435409aff1da7c498d52cfc07e579e38335fa1 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 18 Feb 2023 02:11:03 +0100 Subject: [PATCH 026/373] fix typo --- federation/src/config/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/federation/src/config/index.ts b/federation/src/config/index.ts index 6b3bf6424..52c73ef0a 100644 --- a/federation/src/config/index.ts +++ b/federation/src/config/index.ts @@ -11,7 +11,7 @@ Decimal.set({ */ const constants = { - DB_VERSION: '0060-0061-event_refactoring', + DB_VERSION: '0061-event_refactoring', // DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0 LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info From d411ca76821756295647a69ab27da6871af40863 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 21 Feb 2023 10:42:47 +0100 Subject: [PATCH 027/373] add file change check to test admin workflow --- .github/file-filters.yml | 4 ++++ .github/workflows/test-admin-interface.yml | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 .github/file-filters.yml diff --git a/.github/file-filters.yml b/.github/file-filters.yml new file mode 100644 index 000000000..526cb0c7f --- /dev/null +++ b/.github/file-filters.yml @@ -0,0 +1,4 @@ +# These file filter patterns are used by the action https://github.com/dorny/paths-filter + +admin_locales: &admin_locales + - 'admin/src/locales/**' \ No newline at end of file diff --git a/.github/workflows/test-admin-interface.yml b/.github/workflows/test-admin-interface.yml index d126a9075..cfb888ff7 100644 --- a/.github/workflows/test-admin-interface.yml +++ b/.github/workflows/test-admin-interface.yml @@ -6,6 +6,23 @@ on: - separate-admin-interface-workflow jobs: + # + files-changed: + name: Detect File Changes - Admin Interface + runs-on: ubuntu-latest + outputs: + admin_locales: ${{ steps.changes.outputs.admin_locales }} + 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_admin: name: Docker Build Test - Admin Interface runs-on: ubuntu-latest @@ -59,7 +76,9 @@ jobs: run: cd admin && yarn && yarn run stylelint locales_admin: + if: needs.files-changed.outputs.admin_locales == 'true' name: Locales - Admin Interface + needs: files-changed runs-on: ubuntu-latest steps: - name: Checkout code From ef9ad7e4a8f97094429c3aba953dd7b431ba96d5 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 21 Feb 2023 11:17:36 +0100 Subject: [PATCH 028/373] add file change check for stylelinting to test admin workflow --- .github/file-filters.yml | 6 +++++- .github/workflows/test-admin-interface.yml | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/file-filters.yml b/.github/file-filters.yml index 526cb0c7f..d835f778f 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -1,4 +1,8 @@ # These file filter patterns are used by the action https://github.com/dorny/paths-filter admin_locales: &admin_locales - - 'admin/src/locales/**' \ No newline at end of file + - 'admin/src/locales/**' + +admin_stylelinting: &admin_stylelinting + - 'admin/{components,layouts,pages}/**/*.{scss,vue}' + - 'admin/.stylelintrc.js' diff --git a/.github/workflows/test-admin-interface.yml b/.github/workflows/test-admin-interface.yml index cfb888ff7..a0e81747b 100644 --- a/.github/workflows/test-admin-interface.yml +++ b/.github/workflows/test-admin-interface.yml @@ -12,6 +12,7 @@ jobs: runs-on: ubuntu-latest outputs: admin_locales: ${{ steps.changes.outputs.admin_locales }} + admin_stylelinting: ${{ steps.changes.outputs.admin_stylelinting }} steps: - uses: actions/checkout@v3.3.0 @@ -66,7 +67,9 @@ jobs: run: cd admin && yarn && yarn run lint stylelint_admin: + if: needs.files-changed.outputs.admin_stylelinting == 'true' name: Stylelint - Admin Interface + needs: admin_stylelinting runs-on: ubuntu-latest steps: - name: Checkout code From 84515a51132b35d4cb48885b0b0832fe92ca7c91 Mon Sep 17 00:00:00 2001 From: mahula Date: Tue, 21 Feb 2023 11:19:49 +0100 Subject: [PATCH 029/373] fix typo --- .github/workflows/test-admin-interface.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-admin-interface.yml b/.github/workflows/test-admin-interface.yml index a0e81747b..0fcb1f549 100644 --- a/.github/workflows/test-admin-interface.yml +++ b/.github/workflows/test-admin-interface.yml @@ -69,7 +69,7 @@ jobs: stylelint_admin: if: needs.files-changed.outputs.admin_stylelinting == 'true' name: Stylelint - Admin Interface - needs: admin_stylelinting + needs: files-changed runs-on: ubuntu-latest steps: - name: Checkout code From 56485d2d75fba0ae6e9749b5a77ac4f55b71d0e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Wed, 22 Feb 2023 20:43:19 +0100 Subject: [PATCH 030/373] start adding federation to deployment scripts --- deployment/bare_metal/.env.dist | 2 ++ deployment/bare_metal/start.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/deployment/bare_metal/.env.dist b/deployment/bare_metal/.env.dist index 9c9c7ac82..80c1b36a1 100644 --- a/deployment/bare_metal/.env.dist +++ b/deployment/bare_metal/.env.dist @@ -61,6 +61,8 @@ WEBHOOK_ELOPAGE_SECRET=secret # on an hash created from this topic # FEDERATION_DHT_TOPIC=GRADIDO_HUB # FEDERATION_DHT_SEED=64ebcb0e3ad547848fef4197c6e2332f +FEDERATION_CONFIG_VERSION=v1.2023-01-09 +FEDERATION_API=1_0 # database DATABASE_CONFIG_VERSION=v1.2022-03-18 diff --git a/deployment/bare_metal/start.sh b/deployment/bare_metal/start.sh index 95b89241f..ae98c7e87 100755 --- a/deployment/bare_metal/start.sh +++ b/deployment/bare_metal/start.sh @@ -1,5 +1,18 @@ #!/bin/bash +echo "Before getopt" +for i +do + echo $i +done +args=`getopt b:p: $*` +set -- $args +echo "After getopt" +for i +do + echo "-->$i" +done + # Find current directory & configure paths set -o allexport SCRIPT_PATH=$(realpath $0) @@ -93,10 +106,12 @@ cp -f $PROJECT_ROOT/database/.env $PROJECT_ROOT/database/.env.bak cp -f $PROJECT_ROOT/backend/.env $PROJECT_ROOT/backend/.env.bak cp -f $PROJECT_ROOT/frontend/.env $PROJECT_ROOT/frontend/.env.bak cp -f $PROJECT_ROOT/admin/.env $PROJECT_ROOT/admin/.env.bak +cp -f $PROJECT_ROOT/federation/.env $PROJECT_ROOT/federation/.env.bak envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $PROJECT_ROOT/database/.env.template > $PROJECT_ROOT/database/.env envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $PROJECT_ROOT/backend/.env.template > $PROJECT_ROOT/backend/.env envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $PROJECT_ROOT/frontend/.env.template > $PROJECT_ROOT/frontend/.env envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $PROJECT_ROOT/admin/.env.template > $PROJECT_ROOT/admin/.env +envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $PROJECT_ROOT/federation/.env.template > $PROJECT_ROOT/federation/.env # Install & build database echo 'Updating database' >> $UPDATE_HTML @@ -152,6 +167,19 @@ pm2 delete gradido-admin pm2 start --name gradido-admin "yarn --cwd $PROJECT_ROOT/admin start" -l $GRADIDO_LOG_PATH/pm2.admin.$TODAY.log --log-date-format 'YYYY-MM-DD HH:mm:ss.SSS' pm2 save +# Install & build federation +echo 'Updating federation' >> $UPDATE_HTML +cd $PROJECT_ROOT/federation +# TODO maybe handle this differently? +unset NODE_ENV +yarn install +yarn build +# TODO maybe handle this differently? +export NODE_ENV=production +pm2 delete gradido-federation +pm2 start --name gradido-federation "yarn --cwd $PROJECT_ROOT/federation start" -l $GRADIDO_LOG_PATH/pm2.federation.$TODAY.log --log-date-format 'YYYY-MM-DD HH:mm:ss.SSS' +pm2 save + # let nginx showing gradido echo 'Configuring nginx to serve gradido again' >> $UPDATE_HTML ln -s /etc/nginx/sites-available/gradido.conf /etc/nginx/sites-enabled/ From c9df716eb38bde05f60a9a2115ceb07e5fc85fe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Wed, 22 Feb 2023 22:42:18 +0100 Subject: [PATCH 031/373] add federation-module to deployment script --- deployment/bare_metal/start.sh | 39 +++++++++++++++++++++++----------- federation/src/config/index.ts | 2 +- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/deployment/bare_metal/start.sh b/deployment/bare_metal/start.sh index ae98c7e87..8ec4cfc48 100755 --- a/deployment/bare_metal/start.sh +++ b/deployment/bare_metal/start.sh @@ -1,18 +1,25 @@ #!/bin/bash -echo "Before getopt" -for i -do - echo $i -done -args=`getopt b:p: $*` -set -- $args -echo "After getopt" -for i -do - echo "-->$i" +while [ "$#" -gt 0 ]; do + case "$1" in + -a) ARG_API="${2:-1_0}"; shift 2;; + -b) ARG_BRANCH="${2:-master}"; shift 2;; + + --api-version=*) ARG_API="${1#*=}"; shift 1;; + --branch=*) ARG_BRANCH="${1#*=}"; shift 1;; + --api-version|--branch) echo "$1 requires an argument" >&2; exit 1;; + + -*) echo "unknown option: $1" >&2; exit 1;; + *) handle_argument "$1"; shift 1;; + esac done +echo "==================================================" +echo "Arguments:" +echo " -api-version = $ARG_API" +echo " -branch = $ARG_BRANCH" +echo "==================================================" + # Find current directory & configure paths set -o allexport SCRIPT_PATH=$(realpath $0) @@ -76,7 +83,8 @@ echo 'Stopping all Gradido services' >> $UPDATE_HTML pm2 stop all # git -BRANCH=${1:-master} +# BRANCH=${1:-master} +BRANCH=$ARG_BRANCH echo "Starting with git pull - branch:$BRANCH" >> $UPDATE_HTML cd $PROJECT_ROOT # TODO: this overfetches alot, but ensures we can use start.sh with tags @@ -177,6 +185,13 @@ yarn build # TODO maybe handle this differently? export NODE_ENV=production pm2 delete gradido-federation +# set FEDERATION_PORT from ARG_API +port=${ARG_API//_/} +FEDERATION_PORT=$(($FEDERATION_PORT + $port)) +export FEDERATION_PORT +echo "====================================================" +echo " start federation listening on port=$FEDERATION_PORT +echo "====================================================" pm2 start --name gradido-federation "yarn --cwd $PROJECT_ROOT/federation start" -l $GRADIDO_LOG_PATH/pm2.federation.$TODAY.log --log-date-format 'YYYY-MM-DD HH:mm:ss.SSS' pm2 save diff --git a/federation/src/config/index.ts b/federation/src/config/index.ts index c8a841315..82011a6bc 100644 --- a/federation/src/config/index.ts +++ b/federation/src/config/index.ts @@ -73,7 +73,7 @@ if ( const federation = { // FEDERATION_DHT_TOPIC: process.env.FEDERATION_DHT_TOPIC || null, // FEDERATION_DHT_SEED: process.env.FEDERATION_DHT_SEED || null, - FEDERATION_PORT: process.env.FEDERATION_PORT || 5010, + FEDERATION_PORT: process.env.FEDERATION_PORT || 5000, FEDERATION_API: process.env.FEDERATION_API || '1_0', FEDERATION_COMMUNITY_URL: process.env.FEDERATION_COMMUNITY_URL || null, } From 8ab39765420a14a0487cba153d49e460e07dff3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Wed, 22 Feb 2023 22:57:10 +0100 Subject: [PATCH 032/373] pm2 delete handle case of error as optional --- deployment/bare_metal/start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/bare_metal/start.sh b/deployment/bare_metal/start.sh index 8ec4cfc48..746701206 100755 --- a/deployment/bare_metal/start.sh +++ b/deployment/bare_metal/start.sh @@ -184,7 +184,7 @@ yarn install yarn build # TODO maybe handle this differently? export NODE_ENV=production -pm2 delete gradido-federation +pm2 delete gradido-federation || : # set FEDERATION_PORT from ARG_API port=${ARG_API//_/} FEDERATION_PORT=$(($FEDERATION_PORT + $port)) From 3d7d3ffdeef4b7e3af7f2e4e5f9bd41b4dd763f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Wed, 22 Feb 2023 23:03:29 +0100 Subject: [PATCH 033/373] next try for pm2 delete handling error --- deployment/bare_metal/start.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/deployment/bare_metal/start.sh b/deployment/bare_metal/start.sh index 746701206..a7ffbd036 100755 --- a/deployment/bare_metal/start.sh +++ b/deployment/bare_metal/start.sh @@ -184,7 +184,6 @@ yarn install yarn build # TODO maybe handle this differently? export NODE_ENV=production -pm2 delete gradido-federation || : # set FEDERATION_PORT from ARG_API port=${ARG_API//_/} FEDERATION_PORT=$(($FEDERATION_PORT + $port)) @@ -192,7 +191,7 @@ export FEDERATION_PORT echo "====================================================" echo " start federation listening on port=$FEDERATION_PORT echo "====================================================" -pm2 start --name gradido-federation "yarn --cwd $PROJECT_ROOT/federation start" -l $GRADIDO_LOG_PATH/pm2.federation.$TODAY.log --log-date-format 'YYYY-MM-DD HH:mm:ss.SSS' +pm2 delete gradido-federation || : && pm2 start --name gradido-federation "yarn --cwd $PROJECT_ROOT/federation start" -l $GRADIDO_LOG_PATH/pm2.federation.$TODAY.log --log-date-format 'YYYY-MM-DD HH:mm:ss.SSS' pm2 save # let nginx showing gradido From 3425e5998a84aa35c8e2b0848bf2e6f99bba6359 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Wed, 22 Feb 2023 23:16:07 +0100 Subject: [PATCH 034/373] change federation port settings --- deployment/bare_metal/.env.dist | 1 + deployment/bare_metal/start.sh | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/deployment/bare_metal/.env.dist b/deployment/bare_metal/.env.dist index 80c1b36a1..0e3f2d995 100644 --- a/deployment/bare_metal/.env.dist +++ b/deployment/bare_metal/.env.dist @@ -62,6 +62,7 @@ WEBHOOK_ELOPAGE_SECRET=secret # FEDERATION_DHT_TOPIC=GRADIDO_HUB # FEDERATION_DHT_SEED=64ebcb0e3ad547848fef4197c6e2332f FEDERATION_CONFIG_VERSION=v1.2023-01-09 +FEDERATION_PORT=5000 FEDERATION_API=1_0 # database diff --git a/deployment/bare_metal/start.sh b/deployment/bare_metal/start.sh index a7ffbd036..19d1d8852 100755 --- a/deployment/bare_metal/start.sh +++ b/deployment/bare_metal/start.sh @@ -184,14 +184,16 @@ yarn install yarn build # TODO maybe handle this differently? export NODE_ENV=production +pm2 delete gradido-federation # set FEDERATION_PORT from ARG_API port=${ARG_API//_/} +FEDERATION_PORT=${FEDERATION_PORT:-5000} FEDERATION_PORT=$(($FEDERATION_PORT + $port)) export FEDERATION_PORT echo "====================================================" -echo " start federation listening on port=$FEDERATION_PORT +echo " start federation listening on port=$FEDERATION_PORT" echo "====================================================" -pm2 delete gradido-federation || : && pm2 start --name gradido-federation "yarn --cwd $PROJECT_ROOT/federation start" -l $GRADIDO_LOG_PATH/pm2.federation.$TODAY.log --log-date-format 'YYYY-MM-DD HH:mm:ss.SSS' +pm2 start --name gradido-federation "yarn --cwd $PROJECT_ROOT/federation start" -l $GRADIDO_LOG_PATH/pm2.federation.$TODAY.log --log-date-format 'YYYY-MM-DD HH:mm:ss.SSS' pm2 save # let nginx showing gradido From cc4acd4378fe539106ac0810cebd05a4928ae0b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Wed, 22 Feb 2023 23:52:18 +0100 Subject: [PATCH 035/373] change commandline arg handling --- deployment/bare_metal/start.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/deployment/bare_metal/start.sh b/deployment/bare_metal/start.sh index 19d1d8852..2a2f7b4ea 100755 --- a/deployment/bare_metal/start.sh +++ b/deployment/bare_metal/start.sh @@ -1,9 +1,16 @@ #!/bin/bash +#================================================== +# Commandline Arguments: +# -a value short arg: api-version (default=1_0) +# -b value short arg: branch (default=master) +# --api-version=value arg: api-version (default=1_0) +# --branch=value arg: branch (default=master) +#================================================== while [ "$#" -gt 0 ]; do case "$1" in - -a) ARG_API="${2:-1_0}"; shift 2;; - -b) ARG_BRANCH="${2:-master}"; shift 2;; + -a) ARG_API="$2"; shift 2;; + -b) ARG_BRANCH="$2"; shift 2;; --api-version=*) ARG_API="${1#*=}"; shift 1;; --branch=*) ARG_BRANCH="${1#*=}"; shift 1;; @@ -13,7 +20,13 @@ while [ "$#" -gt 0 ]; do *) handle_argument "$1"; shift 1;; esac done - +if [ -z $ARG_API ]; then + ARG_API="1_0" +fi +if [ -z $ARG_BRANCH ]; then + ARG_BRANCH="master" +fi + echo "==================================================" echo "Arguments:" echo " -api-version = $ARG_API" From fd37107da3da67b565f845b2e9e8073a07ef904e Mon Sep 17 00:00:00 2001 From: mahula Date: Thu, 23 Feb 2023 08:36:29 +0100 Subject: [PATCH 036/373] set allother test workflows tonot run while working in this branch --- .github/workflows/test.yml | 2 +- .github/workflows/test_dht-node.yml | 6 ++++-- .github/workflows/test_federation.yml | 5 ++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 722bef1c1..a435c7425 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,7 @@ name: gradido test CI on: push: branches: - - separate-admin-interface-workflow + - none jobs: ############################################################################## diff --git a/.github/workflows/test_dht-node.yml b/.github/workflows/test_dht-node.yml index 5b3a65a70..35d9bca7d 100644 --- a/.github/workflows/test_dht-node.yml +++ b/.github/workflows/test_dht-node.yml @@ -1,7 +1,9 @@ name: gradido test_dht-node CI -on: push - +on: + push: + branches: + - none jobs: ############################################################################## # JOB: DOCKER BUILD TEST ##################################################### diff --git a/.github/workflows/test_federation.yml b/.github/workflows/test_federation.yml index 2da78758e..b49473af2 100644 --- a/.github/workflows/test_federation.yml +++ b/.github/workflows/test_federation.yml @@ -1,6 +1,9 @@ name: gradido test_federation CI -on: push +on: + push: + branches: + - none jobs: ############################################################################## From 287659af0695fb06ae3254603c6dfb87f951f329 Mon Sep 17 00:00:00 2001 From: mahula Date: Thu, 23 Feb 2023 08:54:33 +0100 Subject: [PATCH 037/373] add file change check for linting to test admin workflow --- .github/file-filters.yml | 6 ++++++ .github/workflows/test-admin-interface.yml | 3 +++ 2 files changed, 9 insertions(+) diff --git a/.github/file-filters.yml b/.github/file-filters.yml index d835f778f..81f44a157 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -6,3 +6,9 @@ admin_locales: &admin_locales 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}' \ No newline at end of file diff --git a/.github/workflows/test-admin-interface.yml b/.github/workflows/test-admin-interface.yml index 0fcb1f549..4faa60550 100644 --- a/.github/workflows/test-admin-interface.yml +++ b/.github/workflows/test-admin-interface.yml @@ -11,6 +11,7 @@ jobs: name: Detect File Changes - Admin Interface runs-on: ubuntu-latest outputs: + admin_linting: ${{ steps.changes.outputs.admin_linting }} admin_locales: ${{ steps.changes.outputs.admin_locales }} admin_stylelinting: ${{ steps.changes.outputs.admin_stylelinting }} steps: @@ -57,7 +58,9 @@ jobs: token: ${{ github.token }} lint_admin: + if: needs.files-changed.outputs.admin_linting == 'true' name: Lint - Admin Interface + needs:files-changed runs-on: ubuntu-latest steps: - name: Checkout code From 6b4579454d5e7b5e660da09a5f19e0613395d582 Mon Sep 17 00:00:00 2001 From: mahula Date: Thu, 23 Feb 2023 08:56:34 +0100 Subject: [PATCH 038/373] add sortscriptsto admin locales file filter --- .github/file-filters.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/file-filters.yml b/.github/file-filters.yml index 81f44a157..99cc32d3e 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -2,6 +2,7 @@ admin_locales: &admin_locales - 'admin/src/locales/**' + - 'admin/scripts/sort*' admin_stylelinting: &admin_stylelinting - 'admin/{components,layouts,pages}/**/*.{scss,vue}' From af6b08bfd7c4aabeb49d74c8dcdee5d8ad194a35 Mon Sep 17 00:00:00 2001 From: mahula Date: Thu, 23 Feb 2023 08:58:27 +0100 Subject: [PATCH 039/373] fix typo --- .github/workflows/test-admin-interface.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-admin-interface.yml b/.github/workflows/test-admin-interface.yml index 4faa60550..a721be8fd 100644 --- a/.github/workflows/test-admin-interface.yml +++ b/.github/workflows/test-admin-interface.yml @@ -60,7 +60,7 @@ jobs: lint_admin: if: needs.files-changed.outputs.admin_linting == 'true' name: Lint - Admin Interface - needs:files-changed + needs: files-changed runs-on: ubuntu-latest steps: - name: Checkout code From 964bdebbda36085f75340a9556c42e291765fae5 Mon Sep 17 00:00:00 2001 From: mahula Date: Thu, 23 Feb 2023 09:54:13 +0100 Subject: [PATCH 040/373] add locales filter to linting filter --- .github/file-filters.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/file-filters.yml b/.github/file-filters.yml index 99cc32d3e..b55174526 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -11,5 +11,10 @@ admin_stylelinting: &admin_stylelinting 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/**/*.{js,vue}' \ No newline at end of file From 72511fb14e83acca3547cfec01ccaabffcb336dd Mon Sep 17 00:00:00 2001 From: mahula Date: Thu, 23 Feb 2023 10:44:49 +0100 Subject: [PATCH 041/373] add file change check for unit tests to test admin workflow --- .github/file-filters.yml | 3 ++- .github/workflows/test-admin-interface.yml | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/file-filters.yml b/.github/file-filters.yml index b55174526..96bcbd7c8 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -17,4 +17,5 @@ admin_linting: &admin_linting admin_unit_testing: &admin_unit_testing - 'admin/package.json' - - 'admin/**/*.{js,vue}' \ No newline at end of file + - 'admin/{jest,vue}.config.js' + - 'admin/{public,run,src,test}/**/*' diff --git a/.github/workflows/test-admin-interface.yml b/.github/workflows/test-admin-interface.yml index a721be8fd..4809059cd 100644 --- a/.github/workflows/test-admin-interface.yml +++ b/.github/workflows/test-admin-interface.yml @@ -14,6 +14,7 @@ jobs: admin_linting: ${{ steps.changes.outputs.admin_linting }} admin_locales: ${{ steps.changes.outputs.admin_locales }} admin_stylelinting: ${{ steps.changes.outputs.admin_stylelinting }} + admin_unit_testing: ${{ steps.changes.outputs.admin_unit_testing }} steps: - uses: actions/checkout@v3.3.0 @@ -37,7 +38,9 @@ jobs: run: docker build --target test -t "gradido/admin:test" admin/ --build-arg NODE_ENV="test" unit_test_admin: + if: needs.files-changed.outputs.admin_unit_testing == 'true' name: Unit Tests - Admin Interface + needs: files-changed runs-on: ubuntu-latest steps: - name: Checkout code From 4d6854463ad9f235d74a3e171239c9f02f3424df Mon Sep 17 00:00:00 2001 From: mahula Date: Thu, 23 Feb 2023 11:10:48 +0100 Subject: [PATCH 042/373] add file change check for building test to test admin workflow --- .github/file-filters.yml | 5 +++++ .github/workflows/test-admin-interface.yml | 3 +++ 2 files changed, 8 insertions(+) diff --git a/.github/file-filters.yml b/.github/file-filters.yml index 96bcbd7c8..fa00c33fb 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -19,3 +19,8 @@ admin_unit_testing: &admin_unit_testing - 'admin/package.json' - 'admin/{jest,vue}.config.js' - 'admin/{public,run,src,test}/**/*' + +admin_docker_building: &admin_docker_building + - 'admin/.dockerignore' + - 'admin/Dockerfile' + - *admin_unit_testing \ No newline at end of file diff --git a/.github/workflows/test-admin-interface.yml b/.github/workflows/test-admin-interface.yml index 4809059cd..44316040b 100644 --- a/.github/workflows/test-admin-interface.yml +++ b/.github/workflows/test-admin-interface.yml @@ -11,6 +11,7 @@ jobs: name: Detect File Changes - Admin Interface runs-on: ubuntu-latest outputs: + admin_docker_building: ${{ steps.changes.outputs.admin_docker_building }} admin_linting: ${{ steps.changes.outputs.admin_linting }} admin_locales: ${{ steps.changes.outputs.admin_locales }} admin_stylelinting: ${{ steps.changes.outputs.admin_stylelinting }} @@ -27,7 +28,9 @@ jobs: list-files: shell build_test_admin: + if: needs.files-changed.outputs.admin_docker_building == 'true' name: Docker Build Test - Admin Interface + needs: files-changed runs-on: ubuntu-latest steps: From 10bbf6dfbd487552c07a4b490032b78ee2c4b8b1 Mon Sep 17 00:00:00 2001 From: mahula Date: Thu, 23 Feb 2023 11:16:33 +0100 Subject: [PATCH 043/373] add file change check for building test to test admin workflow --- .github/workflows/test-admin-interface.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-admin-interface.yml b/.github/workflows/test-admin-interface.yml index 44316040b..60e22b5cd 100644 --- a/.github/workflows/test-admin-interface.yml +++ b/.github/workflows/test-admin-interface.yml @@ -28,7 +28,7 @@ jobs: list-files: shell build_test_admin: - if: needs.files-changed.outputs.admin_docker_building == 'true' + if: needs.files-changed.outputs.admin_docker_building == 'true' name: Docker Build Test - Admin Interface needs: files-changed runs-on: ubuntu-latest From c7d467759895ece24ca260c01fc1b84a3053f7b0 Mon Sep 17 00:00:00 2001 From: mahula Date: Thu, 23 Feb 2023 11:18:46 +0100 Subject: [PATCH 044/373] test change in locaes --- 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 00eef1812..14088fe92 100644 --- a/admin/src/locales/de.json +++ b/admin/src/locales/de.json @@ -13,7 +13,7 @@ "deleted": "Automatische Schöpfung gelöscht!", "deleteNow": "Automatische Creations '{name}' wirklich löschen?", "maxPerCycle": "Wiederholungen", - "memo": "Nachricht", + "memo": "NachrichtTEST", "name": "Name", "newContributionLink": "Neuer Beitragslink", "noContributionLinks": "Es sind keine Beitragslinks angelegt.", From fdb975fe4f78543b1650672e39d5184d6c86042b Mon Sep 17 00:00:00 2001 From: mahula Date: Thu, 23 Feb 2023 11:26:57 +0100 Subject: [PATCH 045/373] exclude locales files from filter for unit tests --- .github/file-filters.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/file-filters.yml b/.github/file-filters.yml index fa00c33fb..9f6ab116a 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -18,7 +18,7 @@ admin_linting: &admin_linting admin_unit_testing: &admin_unit_testing - 'admin/package.json' - 'admin/{jest,vue}.config.js' - - 'admin/{public,run,src,test}/**/*' + - 'admin/{public,run,src!(locales),test}/**/*' admin_docker_building: &admin_docker_building - 'admin/.dockerignore' From 06174a8082ff8f19f2bacc970b2836642ef61f87 Mon Sep 17 00:00:00 2001 From: mahula Date: Thu, 23 Feb 2023 11:26:57 +0100 Subject: [PATCH 046/373] exclude locales files from filter for unit tests --- .github/file-filters.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/file-filters.yml b/.github/file-filters.yml index 9f6ab116a..ff8451785 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -18,7 +18,8 @@ admin_linting: &admin_linting admin_unit_testing: &admin_unit_testing - 'admin/package.json' - 'admin/{jest,vue}.config.js' - - 'admin/{public,run,src!(locales),test}/**/*' + - 'admin/{public,run,test}/**/*' + - 'admin/src/!(locales)/**/*' admin_docker_building: &admin_docker_building - 'admin/.dockerignore' From 83491184033e2b6848599da8bbbf1fa73628728f Mon Sep 17 00:00:00 2001 From: mahula Date: Thu, 23 Feb 2023 11:52:11 +0100 Subject: [PATCH 047/373] test changes --- admin/Dockerfile | 2 +- admin/src/locales/de.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/admin/Dockerfile b/admin/Dockerfile index ed0623a63..6b2e4d9d9 100644 --- a/admin/Dockerfile +++ b/admin/Dockerfile @@ -1,5 +1,5 @@ ################################################################################## -# BASE ########################################################################### +# BASE #######################################################################TEST ################################################################################## FROM node:14.17.0-alpine3.10 as base diff --git a/admin/src/locales/de.json b/admin/src/locales/de.json index 14088fe92..00eef1812 100644 --- a/admin/src/locales/de.json +++ b/admin/src/locales/de.json @@ -13,7 +13,7 @@ "deleted": "Automatische Schöpfung gelöscht!", "deleteNow": "Automatische Creations '{name}' wirklich löschen?", "maxPerCycle": "Wiederholungen", - "memo": "NachrichtTEST", + "memo": "Nachricht", "name": "Name", "newContributionLink": "Neuer Beitragslink", "noContributionLinks": "Es sind keine Beitragslinks angelegt.", From 1181c4b85d73899a36066915c57f05e9de776e8a Mon Sep 17 00:00:00 2001 From: mahula Date: Thu, 23 Feb 2023 11:58:33 +0100 Subject: [PATCH 048/373] test changes --- admin/Dockerfile | 2 +- admin/src/graphql/adminCreateContribution.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/admin/Dockerfile b/admin/Dockerfile index 6b2e4d9d9..ed0623a63 100644 --- a/admin/Dockerfile +++ b/admin/Dockerfile @@ -1,5 +1,5 @@ ################################################################################## -# BASE #######################################################################TEST +# BASE ########################################################################### ################################################################################## FROM node:14.17.0-alpine3.10 as base diff --git a/admin/src/graphql/adminCreateContribution.js b/admin/src/graphql/adminCreateContribution.js index 5ee409c67..1c40f3ff1 100644 --- a/admin/src/graphql/adminCreateContribution.js +++ b/admin/src/graphql/adminCreateContribution.js @@ -1,5 +1,6 @@ import gql from 'graphql-tag' +// TEST export const adminCreateContribution = gql` mutation ($email: String!, $amount: Decimal!, $memo: String!, $creationDate: String!) { adminCreateContribution( From e326e874b8d1d745d31e3ddf44f1f2c29922507d Mon Sep 17 00:00:00 2001 From: mahula Date: Thu, 23 Feb 2023 12:17:29 +0100 Subject: [PATCH 049/373] undo test changes --- admin/src/graphql/adminCreateContribution.js | 1 - 1 file changed, 1 deletion(-) diff --git a/admin/src/graphql/adminCreateContribution.js b/admin/src/graphql/adminCreateContribution.js index 1c40f3ff1..5ee409c67 100644 --- a/admin/src/graphql/adminCreateContribution.js +++ b/admin/src/graphql/adminCreateContribution.js @@ -1,6 +1,5 @@ import gql from 'graphql-tag' -// TEST export const adminCreateContribution = gql` mutation ($email: String!, $amount: Decimal!, $memo: String!, $creationDate: String!) { adminCreateContribution( From 949887fe009657db0af9c58df7ba14c0fc714c0b Mon Sep 17 00:00:00 2001 From: mahula Date: Thu, 23 Feb 2023 13:49:41 +0100 Subject: [PATCH 050/373] set test.yml to be triggered by push to this current branch --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a435c7425..722bef1c1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,7 @@ name: gradido test CI on: push: branches: - - none + - separate-admin-interface-workflow jobs: ############################################################################## From c7559b8606dffc73ad51a550a8b138908d5b6311 Mon Sep 17 00:00:00 2001 From: mahula Date: Thu, 23 Feb 2023 13:56:05 +0100 Subject: [PATCH 051/373] add shortdocumentation to filechange job --- .github/workflows/test-admin-interface.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-admin-interface.yml b/.github/workflows/test-admin-interface.yml index 60e22b5cd..9f589efce 100644 --- a/.github/workflows/test-admin-interface.yml +++ b/.github/workflows/test-admin-interface.yml @@ -6,7 +6,8 @@ on: - separate-admin-interface-workflow 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 From 28c4abc7e9bc2838bda73f26464f02ba9b88ad87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Fri, 24 Feb 2023 00:54:57 +0100 Subject: [PATCH 052/373] start several federation moduls base on FEDERATION_COMMUNITY_APIS --- deployment/bare_metal/.env.dist | 7 ++-- deployment/bare_metal/start.sh | 69 +++++++++++---------------------- federation/src/config/index.ts | 4 +- federation/src/index.ts | 2 +- 4 files changed, 30 insertions(+), 52 deletions(-) diff --git a/deployment/bare_metal/.env.dist b/deployment/bare_metal/.env.dist index 7028966bf..0a4a2db4d 100644 --- a/deployment/bare_metal/.env.dist +++ b/deployment/bare_metal/.env.dist @@ -61,14 +61,13 @@ FEDERATION_DHT_CONFIG_VERSION=v2.2023-02-07 # if you set the value of FEDERATION_DHT_TOPIC, the DHT hyperswarm will start to announce and listen on an hash created from this topic # FEDERATION_DHT_TOPIC=GRADIDO_HUB # FEDERATION_DHT_SEED=64ebcb0e3ad547848fef4197c6e2332f - -FEDERATION_CONFIG_VERSION=v1.2023-01-09 -FEDERATION_PORT=5000 -FEDERATION_API=1_0 FEDERATION_COMMUNITY_URL=http://stage1.gradido.net # the api port is the baseport, which will be added with the api-version, e.g. 1_0 = 5010 FEDERATION_COMMUNITY_API_PORT=5000 +FEDERATION_CONFIG_VERSION=v1.2023-01-09 +FEDERATION_COMMUNITY_APIS=1_0,1_1,2_0 + # database DATABASE_CONFIG_VERSION=v1.2022-03-18 diff --git a/deployment/bare_metal/start.sh b/deployment/bare_metal/start.sh index 39491d699..63c912b55 100755 --- a/deployment/bare_metal/start.sh +++ b/deployment/bare_metal/start.sh @@ -1,38 +1,5 @@ #!/bin/bash -#================================================== -# Commandline Arguments: -# -a value short arg: api-version (default=1_0) -# -b value short arg: branch (default=master) -# --api-version=value arg: api-version (default=1_0) -# --branch=value arg: branch (default=master) -#================================================== -while [ "$#" -gt 0 ]; do - case "$1" in - -a) ARG_API="$2"; shift 2;; - -b) ARG_BRANCH="$2"; shift 2;; - - --api-version=*) ARG_API="${1#*=}"; shift 1;; - --branch=*) ARG_BRANCH="${1#*=}"; shift 1;; - --api-version|--branch) echo "$1 requires an argument" >&2; exit 1;; - - -*) echo "unknown option: $1" >&2; exit 1;; - *) handle_argument "$1"; shift 1;; - esac -done -if [ -z $ARG_API ]; then - ARG_API="1_0" -fi -if [ -z $ARG_BRANCH ]; then - ARG_BRANCH="master" -fi - -echo "==================================================" -echo "Arguments:" -echo " -api-version = $ARG_API" -echo " -branch = $ARG_BRANCH" -echo "==================================================" - # Find current directory & configure paths set -o allexport SCRIPT_PATH=$(realpath $0) @@ -96,8 +63,7 @@ echo 'Stopping all Gradido services' >> $UPDATE_HTML pm2 stop all # git -# BRANCH=${1:-master} -BRANCH=$ARG_BRANCH +BRANCH=${1:-master} echo "Starting with git pull - branch:$BRANCH" >> $UPDATE_HTML cd $PROJECT_ROOT # TODO: this overfetches alot, but ensures we can use start.sh with tags @@ -219,17 +185,28 @@ yarn install yarn build # TODO maybe handle this differently? export NODE_ENV=production -pm2 delete gradido-federation -# set FEDERATION_PORT from ARG_API -port=${ARG_API//_/} -FEDERATION_PORT=${FEDERATION_PORT:-5000} -FEDERATION_PORT=$(($FEDERATION_PORT + $port)) -export FEDERATION_PORT -echo "====================================================" -echo " start federation listening on port=$FEDERATION_PORT" -echo "====================================================" -pm2 start --name gradido-federation "yarn --cwd $PROJECT_ROOT/federation start" -l $GRADIDO_LOG_PATH/pm2.federation.$TODAY.log --log-date-format 'YYYY-MM-DD HH:mm:ss.SSS' -pm2 save +# set FEDERATION_PORT from FEDERATION_COMMUNITY_APIS +IFS="," read -a API_ARRAY <<< $FEDERATION_COMMUNITY_APIS +for api in "${API_ARRAY[@]}" +do + FEDERATION_API=$api + export FEDERATION_API + modulname=gradido-federation-$api + # calculate port by remove '_' and add value of api to baseport + port=${api//_/} + FEDERATION_PORT=${FEDERATION_COMMUNITY_API_PORT:-5000} + FEDERATION_PORT=$(($FEDERATION_PORT + $port)) + export FEDERATION_PORT + echo "====================================================" + echo " start $modulename listening on port=$FEDERATION_PORT" + echo "====================================================" + pm2 delete $modulename + pm2 start --name $modulename "yarn --cwd $PROJECT_ROOT/federation start" -l $GRADIDO_LOG_PATH/pm2.$modulename.$TODAY.log --log-date-format 'YYYY-MM-DD HH:mm:ss.SSS' + pm2 save +done + + + # let nginx showing gradido echo 'Configuring nginx to serve gradido again' >> $UPDATE_HTML diff --git a/federation/src/config/index.ts b/federation/src/config/index.ts index 82011a6bc..de474f517 100644 --- a/federation/src/config/index.ts +++ b/federation/src/config/index.ts @@ -73,8 +73,10 @@ if ( const federation = { // FEDERATION_DHT_TOPIC: process.env.FEDERATION_DHT_TOPIC || null, // FEDERATION_DHT_SEED: process.env.FEDERATION_DHT_SEED || null, - FEDERATION_PORT: process.env.FEDERATION_PORT || 5000, + FEDERATION_COMMUNITY_API_PORT: + process.env.FEDERATION_COMMUNITY_API_PORT || 5000, FEDERATION_API: process.env.FEDERATION_API || '1_0', + FEDERATION_PORT: process.env.FEDERATION_PORT || 5010, FEDERATION_COMMUNITY_URL: process.env.FEDERATION_COMMUNITY_URL || null, } diff --git a/federation/src/index.ts b/federation/src/index.ts index 9096cb260..daf9bfa56 100644 --- a/federation/src/index.ts +++ b/federation/src/index.ts @@ -20,7 +20,7 @@ async function main() { if (CONFIG.GRAPHIQL) { // eslint-disable-next-line no-console console.log( - `GraphIQL available at http://localhost:${CONFIG.FEDERATION_PORT}` + `GraphIQL available at ${CONFIG.FEDERATION_COMMUNITY_URL}:${CONFIG.FEDERATION_PORT}/api` ) } }) From ed010a50f94102f985105c91c11bf220ba8aa9b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Fri, 24 Feb 2023 01:08:02 +0100 Subject: [PATCH 053/373] =?UTF-8?q?correct=20modul-name=C3=ADng=20in=20loo?= =?UTF-8?q?p?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deployment/bare_metal/start.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/bare_metal/start.sh b/deployment/bare_metal/start.sh index 63c912b55..1db9daf4a 100755 --- a/deployment/bare_metal/start.sh +++ b/deployment/bare_metal/start.sh @@ -189,9 +189,9 @@ export NODE_ENV=production IFS="," read -a API_ARRAY <<< $FEDERATION_COMMUNITY_APIS for api in "${API_ARRAY[@]}" do - FEDERATION_API=$api + FEDERATION_API="$api" export FEDERATION_API - modulname=gradido-federation-$api + modulname="gradido-federation-$api" # calculate port by remove '_' and add value of api to baseport port=${api//_/} FEDERATION_PORT=${FEDERATION_COMMUNITY_API_PORT:-5000} From f570c8416857d47028ca85283d8827216d2043a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Fri, 24 Feb 2023 01:17:37 +0100 Subject: [PATCH 054/373] next try to correct modulname in loop --- deployment/bare_metal/start.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/deployment/bare_metal/start.sh b/deployment/bare_metal/start.sh index 1db9daf4a..a86e1be3e 100755 --- a/deployment/bare_metal/start.sh +++ b/deployment/bare_metal/start.sh @@ -189,19 +189,20 @@ export NODE_ENV=production IFS="," read -a API_ARRAY <<< $FEDERATION_COMMUNITY_APIS for api in "${API_ARRAY[@]}" do - FEDERATION_API="$api" - export FEDERATION_API - modulname="gradido-federation-$api" + export FEDERATION_API=$api + echo "FEDERATION_API=$FEDERATION_API" + export MODULENAME=gradido-federation-$api + echo "MODULENAME=$MODULENAME" # calculate port by remove '_' and add value of api to baseport port=${api//_/} FEDERATION_PORT=${FEDERATION_COMMUNITY_API_PORT:-5000} FEDERATION_PORT=$(($FEDERATION_PORT + $port)) export FEDERATION_PORT echo "====================================================" - echo " start $modulename listening on port=$FEDERATION_PORT" + echo " start $MODULENAME listening on port=$FEDERATION_PORT" echo "====================================================" - pm2 delete $modulename - pm2 start --name $modulename "yarn --cwd $PROJECT_ROOT/federation start" -l $GRADIDO_LOG_PATH/pm2.$modulename.$TODAY.log --log-date-format 'YYYY-MM-DD HH:mm:ss.SSS' + pm2 delete $MODULENAME + pm2 start --name $MODULENAME "yarn --cwd $PROJECT_ROOT/federation start" -l $GRADIDO_LOG_PATH/pm2.$MODULENAME.$TODAY.log --log-date-format 'YYYY-MM-DD HH:mm:ss.SSS' pm2 save done From 132f92956b7e5662c925a8510b9ac84c2458b0f6 Mon Sep 17 00:00:00 2001 From: mahula Date: Fri, 24 Feb 2023 08:23:18 +0100 Subject: [PATCH 055/373] set file change filter for admin test workflow to main directory --- .github/file-filters.yml | 5 ++++- .github/workflows/test-admin-interface.yml | 16 ++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/file-filters.yml b/.github/file-filters.yml index ff8451785..12832aaca 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -24,4 +24,7 @@ admin_unit_testing: &admin_unit_testing admin_docker_building: &admin_docker_building - 'admin/.dockerignore' - 'admin/Dockerfile' - - *admin_unit_testing \ No newline at end of file + - *admin_unit_testing + +admin_main: &admin_main + - 'admin/**/*' \ No newline at end of file diff --git a/.github/workflows/test-admin-interface.yml b/.github/workflows/test-admin-interface.yml index 9f589efce..7bdfa84cf 100644 --- a/.github/workflows/test-admin-interface.yml +++ b/.github/workflows/test-admin-interface.yml @@ -12,11 +12,7 @@ jobs: name: Detect File Changes - Admin Interface runs-on: ubuntu-latest outputs: - admin_docker_building: ${{ steps.changes.outputs.admin_docker_building }} - admin_linting: ${{ steps.changes.outputs.admin_linting }} - admin_locales: ${{ steps.changes.outputs.admin_locales }} - admin_stylelinting: ${{ steps.changes.outputs.admin_stylelinting }} - admin_unit_testing: ${{ steps.changes.outputs.admin_unit_testing }} + admin_main: ${{ steps.changes.outputs.admin_main }} steps: - uses: actions/checkout@v3.3.0 @@ -29,7 +25,7 @@ jobs: list-files: shell build_test_admin: - if: needs.files-changed.outputs.admin_docker_building == 'true' + if: needs.files-changed.outputs.admin_main == 'true' name: Docker Build Test - Admin Interface needs: files-changed runs-on: ubuntu-latest @@ -42,7 +38,7 @@ jobs: run: docker build --target test -t "gradido/admin:test" admin/ --build-arg NODE_ENV="test" unit_test_admin: - if: needs.files-changed.outputs.admin_unit_testing == 'true' + if: needs.files-changed.outputs.admin_main == 'true' name: Unit Tests - Admin Interface needs: files-changed runs-on: ubuntu-latest @@ -65,7 +61,7 @@ jobs: token: ${{ github.token }} lint_admin: - if: needs.files-changed.outputs.admin_linting == 'true' + if: needs.files-changed.outputs.admin_main == 'true' name: Lint - Admin Interface needs: files-changed runs-on: ubuntu-latest @@ -77,7 +73,7 @@ jobs: run: cd admin && yarn && yarn run lint stylelint_admin: - if: needs.files-changed.outputs.admin_stylelinting == 'true' + if: needs.files-changed.outputs.admin_main == 'true' name: Stylelint - Admin Interface needs: files-changed runs-on: ubuntu-latest @@ -89,7 +85,7 @@ jobs: run: cd admin && yarn && yarn run stylelint locales_admin: - if: needs.files-changed.outputs.admin_locales == 'true' + if: needs.files-changed.outputs.admin_main == 'true' name: Locales - Admin Interface needs: files-changed runs-on: ubuntu-latest From adea7c1c155c3d35cc26cfe8db8f4870baf0ac39 Mon Sep 17 00:00:00 2001 From: mahula Date: Fri, 24 Feb 2023 12:22:53 +0100 Subject: [PATCH 056/373] rename admit test workflow jobs --- .github/workflows/test-admin-interface.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-admin-interface.yml b/.github/workflows/test-admin-interface.yml index 7bdfa84cf..53bd85ca5 100644 --- a/.github/workflows/test-admin-interface.yml +++ b/.github/workflows/test-admin-interface.yml @@ -24,7 +24,7 @@ jobs: filters: .github/file-filters.yml list-files: shell - build_test_admin: + build_test: if: needs.files-changed.outputs.admin_main == 'true' name: Docker Build Test - Admin Interface needs: files-changed @@ -37,7 +37,7 @@ jobs: - name: Admin Interface | Build 'test' image run: docker build --target test -t "gradido/admin:test" admin/ --build-arg NODE_ENV="test" - unit_test_admin: + unit_test: if: needs.files-changed.outputs.admin_main == 'true' name: Unit Tests - Admin Interface needs: files-changed @@ -60,7 +60,7 @@ jobs: min_coverage: 97 token: ${{ github.token }} - lint_admin: + lint: if: needs.files-changed.outputs.admin_main == 'true' name: Lint - Admin Interface needs: files-changed @@ -72,7 +72,7 @@ jobs: - name: Admin Interface | Lint run: cd admin && yarn && yarn run lint - stylelint_admin: + stylelint: if: needs.files-changed.outputs.admin_main == 'true' name: Stylelint - Admin Interface needs: files-changed @@ -84,7 +84,7 @@ jobs: - name: Admin Interface | Stylelint run: cd admin && yarn && yarn run stylelint - locales_admin: + locales: if: needs.files-changed.outputs.admin_main == 'true' name: Locales - Admin Interface needs: files-changed From 289ed452d1d99bf25dce05dd8163c8585673190b Mon Sep 17 00:00:00 2001 From: mahula Date: Fri, 24 Feb 2023 13:03:04 +0100 Subject: [PATCH 057/373] rename file filter for admin test workflow --- .github/file-filters.yml | 2 +- .github/workflows/test-admin-interface.yml | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/file-filters.yml b/.github/file-filters.yml index 12832aaca..d6c53c0c8 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -26,5 +26,5 @@ admin_docker_building: &admin_docker_building - 'admin/Dockerfile' - *admin_unit_testing -admin_main: &admin_main +admin: &admin - 'admin/**/*' \ No newline at end of file diff --git a/.github/workflows/test-admin-interface.yml b/.github/workflows/test-admin-interface.yml index 53bd85ca5..1d152a898 100644 --- a/.github/workflows/test-admin-interface.yml +++ b/.github/workflows/test-admin-interface.yml @@ -12,7 +12,7 @@ jobs: name: Detect File Changes - Admin Interface runs-on: ubuntu-latest outputs: - admin_main: ${{ steps.changes.outputs.admin_main }} + admin: ${{ steps.changes.outputs.admin }} steps: - uses: actions/checkout@v3.3.0 @@ -25,7 +25,7 @@ jobs: list-files: shell build_test: - if: needs.files-changed.outputs.admin_main == 'true' + if: needs.files-changed.outputs.admin == 'true' name: Docker Build Test - Admin Interface needs: files-changed runs-on: ubuntu-latest @@ -38,7 +38,7 @@ jobs: run: docker build --target test -t "gradido/admin:test" admin/ --build-arg NODE_ENV="test" unit_test: - if: needs.files-changed.outputs.admin_main == 'true' + if: needs.files-changed.outputs.admin == 'true' name: Unit Tests - Admin Interface needs: files-changed runs-on: ubuntu-latest @@ -61,7 +61,7 @@ jobs: token: ${{ github.token }} lint: - if: needs.files-changed.outputs.admin_main == 'true' + if: needs.files-changed.outputs.admin == 'true' name: Lint - Admin Interface needs: files-changed runs-on: ubuntu-latest @@ -73,7 +73,7 @@ jobs: run: cd admin && yarn && yarn run lint stylelint: - if: needs.files-changed.outputs.admin_main == 'true' + if: needs.files-changed.outputs.admin == 'true' name: Stylelint - Admin Interface needs: files-changed runs-on: ubuntu-latest @@ -85,7 +85,7 @@ jobs: run: cd admin && yarn && yarn run stylelint locales: - if: needs.files-changed.outputs.admin_main == 'true' + if: needs.files-changed.outputs.admin == 'true' name: Locales - Admin Interface needs: files-changed runs-on: ubuntu-latest From 1473e01331df6089786491acb2409360b8931df6 Mon Sep 17 00:00:00 2001 From: mahula Date: Fri, 24 Feb 2023 13:16:14 +0100 Subject: [PATCH 058/373] test admin file filter with change to admin/Dockerfile --- admin/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/Dockerfile b/admin/Dockerfile index ed0623a63..6b2e4d9d9 100644 --- a/admin/Dockerfile +++ b/admin/Dockerfile @@ -1,5 +1,5 @@ ################################################################################## -# BASE ########################################################################### +# BASE #######################################################################TEST ################################################################################## FROM node:14.17.0-alpine3.10 as base From 2d51d6b581fca47ee3bb78b22b03c05cccae9050 Mon Sep 17 00:00:00 2001 From: mahula Date: Fri, 24 Feb 2023 13:26:52 +0100 Subject: [PATCH 059/373] test admin file filter with change to admin/public --- admin/Dockerfile | 2 +- admin/{public => public_TEST}/favicon.png | Bin .../img/brand/gradido_logo_w.png | Bin admin/{public => public_TEST}/img/brand/green.png | Bin .../{public => public_TEST}/img/elopage_favicon.png | Bin admin/{public => public_TEST}/img/gdd-coin.png | Bin admin/{public => public_TEST}/index.html | 0 7 files changed, 1 insertion(+), 1 deletion(-) rename admin/{public => public_TEST}/favicon.png (100%) rename admin/{public => public_TEST}/img/brand/gradido_logo_w.png (100%) rename admin/{public => public_TEST}/img/brand/green.png (100%) rename admin/{public => public_TEST}/img/elopage_favicon.png (100%) rename admin/{public => public_TEST}/img/gdd-coin.png (100%) rename admin/{public => public_TEST}/index.html (100%) diff --git a/admin/Dockerfile b/admin/Dockerfile index 6b2e4d9d9..ed0623a63 100644 --- a/admin/Dockerfile +++ b/admin/Dockerfile @@ -1,5 +1,5 @@ ################################################################################## -# BASE #######################################################################TEST +# BASE ########################################################################### ################################################################################## FROM node:14.17.0-alpine3.10 as base diff --git a/admin/public/favicon.png b/admin/public_TEST/favicon.png similarity index 100% rename from admin/public/favicon.png rename to admin/public_TEST/favicon.png diff --git a/admin/public/img/brand/gradido_logo_w.png b/admin/public_TEST/img/brand/gradido_logo_w.png similarity index 100% rename from admin/public/img/brand/gradido_logo_w.png rename to admin/public_TEST/img/brand/gradido_logo_w.png diff --git a/admin/public/img/brand/green.png b/admin/public_TEST/img/brand/green.png similarity index 100% rename from admin/public/img/brand/green.png rename to admin/public_TEST/img/brand/green.png diff --git a/admin/public/img/elopage_favicon.png b/admin/public_TEST/img/elopage_favicon.png similarity index 100% rename from admin/public/img/elopage_favicon.png rename to admin/public_TEST/img/elopage_favicon.png diff --git a/admin/public/img/gdd-coin.png b/admin/public_TEST/img/gdd-coin.png similarity index 100% rename from admin/public/img/gdd-coin.png rename to admin/public_TEST/img/gdd-coin.png diff --git a/admin/public/index.html b/admin/public_TEST/index.html similarity index 100% rename from admin/public/index.html rename to admin/public_TEST/index.html From d8a786c55b49afad4471d45b9a7fca1bf064ad46 Mon Sep 17 00:00:00 2001 From: mahula Date: Fri, 24 Feb 2023 13:37:31 +0100 Subject: [PATCH 060/373] undo change to admin/public --- admin/{public_TEST => public}/favicon.png | Bin .../img/brand/gradido_logo_w.png | Bin admin/{public_TEST => public}/img/brand/green.png | Bin .../{public_TEST => public}/img/elopage_favicon.png | Bin admin/{public_TEST => public}/img/gdd-coin.png | Bin admin/{public_TEST => public}/index.html | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename admin/{public_TEST => public}/favicon.png (100%) rename admin/{public_TEST => public}/img/brand/gradido_logo_w.png (100%) rename admin/{public_TEST => public}/img/brand/green.png (100%) rename admin/{public_TEST => public}/img/elopage_favicon.png (100%) rename admin/{public_TEST => public}/img/gdd-coin.png (100%) rename admin/{public_TEST => public}/index.html (100%) diff --git a/admin/public_TEST/favicon.png b/admin/public/favicon.png similarity index 100% rename from admin/public_TEST/favicon.png rename to admin/public/favicon.png diff --git a/admin/public_TEST/img/brand/gradido_logo_w.png b/admin/public/img/brand/gradido_logo_w.png similarity index 100% rename from admin/public_TEST/img/brand/gradido_logo_w.png rename to admin/public/img/brand/gradido_logo_w.png diff --git a/admin/public_TEST/img/brand/green.png b/admin/public/img/brand/green.png similarity index 100% rename from admin/public_TEST/img/brand/green.png rename to admin/public/img/brand/green.png diff --git a/admin/public_TEST/img/elopage_favicon.png b/admin/public/img/elopage_favicon.png similarity index 100% rename from admin/public_TEST/img/elopage_favicon.png rename to admin/public/img/elopage_favicon.png diff --git a/admin/public_TEST/img/gdd-coin.png b/admin/public/img/gdd-coin.png similarity index 100% rename from admin/public_TEST/img/gdd-coin.png rename to admin/public/img/gdd-coin.png diff --git a/admin/public_TEST/index.html b/admin/public/index.html similarity index 100% rename from admin/public_TEST/index.html rename to admin/public/index.html From 1f98fa562147eaa5e84995ecd13d0480d4bd9dd4 Mon Sep 17 00:00:00 2001 From: mahula Date: Fri, 24 Feb 2023 13:39:08 +0100 Subject: [PATCH 061/373] test admin file filter with change to admin/src/components/ContributionMessages/slots/ContributionMessagesListItem.vue --- .../slots/ContributionMessagesListItem.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/admin/src/components/ContributionMessages/slots/ContributionMessagesListItem.vue b/admin/src/components/ContributionMessages/slots/ContributionMessagesListItem.vue index 53006cff5..20cdfd5e6 100644 --- a/admin/src/components/ContributionMessages/slots/ContributionMessagesListItem.vue +++ b/admin/src/components/ContributionMessages/slots/ContributionMessagesListItem.vue @@ -1,15 +1,17 @@ diff --git a/admin/src/graphql/adminOpenCreations.js b/admin/src/graphql/adminOpenCreations.js new file mode 100644 index 000000000..0e766c0f7 --- /dev/null +++ b/admin/src/graphql/adminOpenCreations.js @@ -0,0 +1,11 @@ +import gql from 'graphql-tag' + +export const adminOpenCreations = gql` + query ($userId: Int!) { + adminOpenCreations(userId: $userId) { + year + month + amount + } + } +` diff --git a/admin/src/graphql/openCreations.js b/admin/src/graphql/openCreations.js deleted file mode 100644 index 010ed62df..000000000 --- a/admin/src/graphql/openCreations.js +++ /dev/null @@ -1,11 +0,0 @@ -import gql from 'graphql-tag' - -export const openCreations = gql` - query ($userId: Int) { - openCreations(userId: $userId) { - year - month - amount - } - } -` diff --git a/admin/src/mixins/creationMonths.js b/admin/src/mixins/creationMonths.js index c26dc5b02..57e0ab17e 100644 --- a/admin/src/mixins/creationMonths.js +++ b/admin/src/mixins/creationMonths.js @@ -1,9 +1,11 @@ +import { adminOpenCreations } from '../graphql/adminOpenCreations' + export const creationMonths = { - props: { - creation: { - type: Array, - default: () => [1000, 1000, 1000], - }, + data() { + return { + creation: [1000, 1000, 1000], + userId: 0, + } }, computed: { creationDates() { @@ -38,4 +40,23 @@ export const creationMonths = { return this.creationDates.map((date) => this.$d(date, 'monthShort')).join(' | ') }, }, + apollo: { + OpenCreations: { + query() { + return adminOpenCreations + }, + variables() { + return { + userId: this.userId, + } + }, + fetchPolicy: 'no-cache', + update({ adminOpenCreations }) { + this.creation = adminOpenCreations.map((obj) => obj.amount) + }, + error({ message }) { + this.toastError(message) + }, + }, + }, } From edd42f02edc4ab67e1b47b2a13221461347999b3 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 10 Mar 2023 14:08:08 +0100 Subject: [PATCH 237/373] fix edit contribution formular, remove unused methods --- .../components/EditCreationFormular.spec.js | 120 ++++++++++-------- admin/src/components/EditCreationFormular.vue | 12 +- .../Tables/OpenCreationsTable.spec.js | 6 +- .../components/Tables/OpenCreationsTable.vue | 22 +--- admin/src/graphql/adminUpdateContribution.js | 1 - 5 files changed, 76 insertions(+), 85 deletions(-) diff --git a/admin/src/components/EditCreationFormular.spec.js b/admin/src/components/EditCreationFormular.spec.js index 4a304dc79..ee0458ba2 100644 --- a/admin/src/components/EditCreationFormular.spec.js +++ b/admin/src/components/EditCreationFormular.spec.js @@ -1,19 +1,18 @@ import { mount } from '@vue/test-utils' import EditCreationFormular from './EditCreationFormular' import { toastErrorSpy, toastSuccessSpy } from '../../test/testSetup' +import VueApollo from 'vue-apollo' +import { createMockClient } from 'mock-apollo-client' +import { adminOpenCreations } from '../graphql/adminOpenCreations' +import { adminUpdateContribution } from '../graphql/adminUpdateContribution' + +const mockClient = createMockClient() +const apolloProvider = new VueApollo({ + defaultClient: mockClient, +}) const localVue = global.localVue - -const apolloMutateMock = jest.fn().mockResolvedValue({ - data: { - adminUpdateContribution: { - creation: [0, 0, 0], - amount: 500, - date: new Date(), - memo: 'Test Schöpfung 2', - }, - }, -}) +localVue.use(VueApollo) const stateCommitMock = jest.fn() @@ -23,22 +22,18 @@ const mocks = { const date = new Date(d) return date.toISOString().split('T')[0] }), - $apollo: { - mutate: apolloMutateMock, - }, $store: { commit: stateCommitMock, }, } -const now = new Date(Date.now()) +const now = new Date() const getCreationDate = (sub) => { const date = sub === 0 ? now : new Date(now.getFullYear(), now.getMonth() - sub, 1, 0) return date.toISOString().split('T')[0] } const propsData = { - creation: [200, 400, 600], creationUserData: { memo: 'Test schöpfung 1', amount: 100, @@ -46,20 +41,65 @@ const propsData = { }, item: { id: 0, - email: 'bob@baumeister.de', + amount: '300', + contributionDate: `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}`, }, } +const data = () => { + return { creation: ['1000', '1000', '400'] } +} + describe('EditCreationFormular', () => { let wrapper + const adminUpdateContributionMock = jest.fn() + const adminOpenCreationsMock = jest.fn() + mockClient.setRequestHandler( + adminOpenCreations, + adminOpenCreationsMock.mockResolvedValue({ + data: { + adminOpenCreations: [ + { + month: new Date(now.getFullYear(), now.getMonth() - 2).getMonth(), + year: new Date(now.getFullYear(), now.getMonth() - 2).getFullYear(), + amount: '1000', + }, + { + month: new Date(now.getFullYear(), now.getMonth() - 1).getMonth(), + year: new Date(now.getFullYear(), now.getMonth() - 1).getFullYear(), + amount: '1000', + }, + { + month: now.getMonth(), + year: now.getFullYear(), + amount: '400', + }, + ], + }, + }), + ) + mockClient.setRequestHandler( + adminUpdateContribution, + adminUpdateContributionMock.mockResolvedValue({ + data: { + adminUpdateContribution: { + amount: '600', + date: new Date(), + memo: 'This is my memo', + }, + }, + }), + ) + const Wrapper = () => { - return mount(EditCreationFormular, { localVue, mocks, propsData }) + return mount(EditCreationFormular, { localVue, mocks, propsData, data, apolloProvider }) } describe('mount', () => { - beforeEach(() => { + beforeEach(async () => { wrapper = Wrapper() + await wrapper.vm.$nextTick() }) it('has a DIV element with the class.component-edit-creation-formular', () => { @@ -89,42 +129,16 @@ describe('EditCreationFormular', () => { }) it('calls the API', () => { - expect(apolloMutateMock).toBeCalledWith( - expect.objectContaining({ - variables: { - id: 0, - email: 'bob@baumeister.de', - creationDate: getCreationDate(0), - amount: 500, - memo: 'Test Schöpfung 2', - }, - }), - ) - }) - - it('emits update-user-data', () => { - expect(wrapper.emitted('update-user-data')).toEqual([ - [ - { - id: 0, - email: 'bob@baumeister.de', - }, - [0, 0, 0], - ], - ]) + expect(adminUpdateContributionMock).toBeCalledWith({ + id: 0, + creationDate: getCreationDate(0), + amount: 500, + memo: 'Test Schöpfung 2', + }) }) it('emits update-creation-data', () => { - expect(wrapper.emitted('update-creation-data')).toEqual([ - [ - { - amount: 500, - date: expect.any(Date), - memo: 'Test Schöpfung 2', - row: expect.any(Object), - }, - ], - ]) + expect(wrapper.emitted('update-creation-data')).toBeTruthy() }) it('toasts a success message', () => { @@ -134,7 +148,7 @@ describe('EditCreationFormular', () => { describe('change and save memo and value with error', () => { beforeEach(async () => { - apolloMutateMock.mockRejectedValue({ message: 'Oh no!' }) + adminUpdateContributionMock.mockRejectedValue({ message: 'Oh no!' }) await wrapper.find('input[type="number"]').setValue(500) await wrapper.find('textarea').setValue('Test Schöpfung 2') await wrapper.find('.test-submit').trigger('click') diff --git a/admin/src/components/EditCreationFormular.vue b/admin/src/components/EditCreationFormular.vue index 1d22460c7..994a734f6 100644 --- a/admin/src/components/EditCreationFormular.vue +++ b/admin/src/components/EditCreationFormular.vue @@ -108,6 +108,7 @@ export default { }, methods: { submitCreation() { + // console.log('submitCreation', this.selected) this.$apollo .mutate({ mutation: adminUpdateContribution, @@ -119,12 +120,7 @@ export default { }, }) .then((result) => { - this.$emit('update-creation-data', { - amount: Number(result.data.adminUpdateContribution.amount), - date: result.data.adminUpdateContribution.date, - memo: result.data.adminUpdateContribution.memo, - row: this.row, - }) + this.$emit('update-creation-data') this.toastSuccess( this.$t('creation_form.toasted_update', { value: this.value, @@ -151,7 +147,9 @@ export default { computed: { creationIndex() { const month = this.$d(new Date(this.item.contributionDate), 'month') - return this.radioOptions.findIndex((obj) => obj.item.short === month) + return this.radioOptions.findIndex((obj) => { + return obj.item.short === month + }) }, selectedComputed() { return this.radioOptions[this.creationIndex].item diff --git a/admin/src/components/Tables/OpenCreationsTable.spec.js b/admin/src/components/Tables/OpenCreationsTable.spec.js index 6542dab31..4cd40017c 100644 --- a/admin/src/components/Tables/OpenCreationsTable.spec.js +++ b/admin/src/components/Tables/OpenCreationsTable.spec.js @@ -17,7 +17,7 @@ const propsData = { amount: 300, memo: 'Aktives Grundeinkommen für Januar 2022', date: '2022-01-01T00:00:00.000Z', - moderator: 1, + moderatorId: 1, creation: [700, 1000, 1000], __typename: 'PendingCreation', }, @@ -29,7 +29,7 @@ const propsData = { amount: 210, memo: 'Aktives Grundeinkommen für Januar 2022', date: '2022-01-01T00:00:00.000Z', - moderator: null, + moderatorId: null, creation: [790, 1000, 1000], __typename: 'PendingCreation', }, @@ -41,7 +41,7 @@ const propsData = { amount: 330, memo: 'Aktives Grundeinkommen für Januar 2022', date: '2022-01-01T00:00:00.000Z', - moderator: 1, + moderatorId: 1, creation: [670, 1000, 1000], __typename: 'PendingCreation', }, diff --git a/admin/src/components/Tables/OpenCreationsTable.vue b/admin/src/components/Tables/OpenCreationsTable.vue index 3b89a7d8c..9e0f3c747 100644 --- a/admin/src/components/Tables/OpenCreationsTable.vue +++ b/admin/src/components/Tables/OpenCreationsTable.vue @@ -96,7 +96,7 @@ :item="row.item" :row="row" :creationUserData="creationUserData" - @update-creation-data="updateCreationData" + @update-creation-data="$emit('update-contributions')" />
@@ -145,16 +145,6 @@ export default { required: true, }, }, - data() { - return { - creationUserData: { - amount: null, - date: null, - memo: null, - moderator: null, - }, - } - }, methods: { myself(item) { return ( @@ -173,16 +163,6 @@ export default { if (item.state === 'IN_PROGRESS') return 'table-primary' if (item.state === 'PENDING') return 'table-primary' }, - updateCreationData(data) { - const row = data.row - this.$emit('update-contributions', data) - delete data.row - this.creationUserData = { ...this.creationUserData, ...data } - row.toggleDetails() - }, - updateUserData(rowItem, newCreation) { - rowItem.creation = newCreation - }, updateState(id) { this.$emit('update-state', id) }, diff --git a/admin/src/graphql/adminUpdateContribution.js b/admin/src/graphql/adminUpdateContribution.js index 7738640e7..c52a0cbc4 100644 --- a/admin/src/graphql/adminUpdateContribution.js +++ b/admin/src/graphql/adminUpdateContribution.js @@ -6,7 +6,6 @@ export const adminUpdateContribution = gql` amount date memo - creation } } ` From 0f01027f6b8ae8cfc44c143511b18f05969d7d45 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 10 Mar 2023 14:11:17 +0100 Subject: [PATCH 238/373] fix open creation tests. remove tests for removed methods --- .../Tables/OpenCreationsTable.spec.js | 44 ------------------- 1 file changed, 44 deletions(-) diff --git a/admin/src/components/Tables/OpenCreationsTable.spec.js b/admin/src/components/Tables/OpenCreationsTable.spec.js index 4cd40017c..cfb91be0d 100644 --- a/admin/src/components/Tables/OpenCreationsTable.spec.js +++ b/admin/src/components/Tables/OpenCreationsTable.spec.js @@ -5,7 +5,6 @@ const localVue = global.localVue const apolloMutateMock = jest.fn().mockResolvedValue({}) const apolloQueryMock = jest.fn().mockResolvedValue({}) -const toggleDetailsMock = jest.fn() const propsData = { items: [ @@ -132,14 +131,6 @@ describe('OpenCreationsTable', () => { }) }) - describe('call updateUserData', () => { - it('user creations has updated data', async () => { - wrapper.vm.updateUserData(propsData.items[0], [444, 555, 666]) - await wrapper.vm.$nextTick() - expect(wrapper.vm.items[0].creation).toEqual([444, 555, 666]) - }) - }) - describe('call updateState', () => { beforeEach(() => { wrapper.vm.updateState(4) @@ -149,40 +140,5 @@ describe('OpenCreationsTable', () => { expect(wrapper.vm.$root.$emit('update-state', 4)).toBeTruthy() }) }) - - describe('call updateCreationData', () => { - const date = new Date() - beforeEach(() => { - wrapper.vm.updateCreationData({ - amount: Number(80.0), - date: date, - memo: 'Test memo', - row: { - item: {}, - detailsShowing: false, - toggleDetails: toggleDetailsMock, - }, - }) - }) - - it('emits update-state', () => { - expect( - wrapper.vm.$emit('update-contributions', { - amount: Number(80.0), - date: date, - memo: 'Test memo', - row: { - item: {}, - detailsShowing: false, - toggleDetails: toggleDetailsMock, - }, - }), - ).toBeTruthy() - }) - - it('calls toggleDetails', () => { - expect(toggleDetailsMock).toBeCalled() - }) - }) }) }) From cef0e00f6eec4451997a517cb6a0b496d8c87ef4 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 10 Mar 2023 14:22:07 +0100 Subject: [PATCH 239/373] fix tests --- admin/src/components/CreationFormular.spec.js | 79 +++++++++++++------ admin/src/components/CreationFormular.vue | 3 +- 2 files changed, 56 insertions(+), 26 deletions(-) diff --git a/admin/src/components/CreationFormular.spec.js b/admin/src/components/CreationFormular.spec.js index 5dba2d931..c22b319a9 100644 --- a/admin/src/components/CreationFormular.spec.js +++ b/admin/src/components/CreationFormular.spec.js @@ -2,14 +2,18 @@ import { mount } from '@vue/test-utils' import CreationFormular from './CreationFormular' import { adminCreateContribution } from '../graphql/adminCreateContribution' import { toastErrorSpy, toastSuccessSpy } from '../../test/testSetup' +import VueApollo from 'vue-apollo' +import { createMockClient } from 'mock-apollo-client' +import { adminOpenCreations } from '../graphql/adminOpenCreations' + +const mockClient = createMockClient() +const apolloProvider = new VueApollo({ + defaultClient: mockClient, +}) const localVue = global.localVue +localVue.use(VueApollo) -const apolloMutateMock = jest.fn().mockResolvedValue({ - data: { - adminCreateContribution: [0, 0, 0], - }, -}) const stateCommitMock = jest.fn() const mocks = { @@ -18,9 +22,6 @@ const mocks = { const date = new Date(d) return date.toISOString().split('T')[0] }), - $apollo: { - mutate: apolloMutateMock, - }, $store: { commit: stateCommitMock, }, @@ -31,7 +32,8 @@ const propsData = { creation: [], } -const now = new Date(Date.now()) +const now = new Date() + const getCreationDate = (sub) => { const date = sub === 0 ? now : new Date(now.getFullYear(), now.getMonth() - sub, 1, 0) return date.toISOString().split('T')[0] @@ -40,8 +42,43 @@ const getCreationDate = (sub) => { describe('CreationFormular', () => { let wrapper + const adminOpenCreationsMock = jest.fn() + const adminCreateContributionMock = jest.fn() + mockClient.setRequestHandler( + adminOpenCreations, + adminOpenCreationsMock.mockResolvedValue({ + data: { + adminOpenCreations: [ + { + month: new Date(now.getFullYear(), now.getMonth() - 2).getMonth(), + year: new Date(now.getFullYear(), now.getMonth() - 2).getFullYear(), + amount: '200', + }, + { + month: new Date(now.getFullYear(), now.getMonth() - 1).getMonth(), + year: new Date(now.getFullYear(), now.getMonth() - 1).getFullYear(), + amount: '400', + }, + { + month: now.getMonth(), + year: now.getFullYear(), + amount: '600', + }, + ], + }, + }), + ) + mockClient.setRequestHandler( + adminCreateContribution, + adminCreateContributionMock.mockResolvedValue({ + data: { + adminCreateContribution: [0, 0, 0], + }, + }), + ) + const Wrapper = () => { - return mount(CreationFormular, { localVue, mocks, propsData }) + return mount(CreationFormular, { localVue, mocks, propsData, apolloProvider }) } describe('mount', () => { @@ -107,17 +144,11 @@ describe('CreationFormular', () => { }) it('sends ... to apollo', () => { - expect(apolloMutateMock).toBeCalledWith( - expect.objectContaining({ - mutation: adminCreateContribution, - variables: { - email: 'benjamin@bluemchen.de', - creationDate: getCreationDate(2), - amount: 90, - memo: 'Test create coins', - }, - }), - ) + expect(adminCreateContributionMock).toBeCalledWith({ + creationDate: getCreationDate(2), + amount: 90, + memo: 'Test create coins', + }) }) it('emits update-user-data', () => { @@ -144,7 +175,7 @@ describe('CreationFormular', () => { describe('sendForm with server error', () => { beforeEach(async () => { - apolloMutateMock.mockRejectedValueOnce({ message: 'Ouch!' }) + adminCreateContributionMock.mockRejectedValueOnce({ message: 'Ouch!' }) await wrapper.find('.test-submit').trigger('click') }) @@ -212,7 +243,7 @@ describe('CreationFormular', () => { }) it('sends ... to apollo', () => { - expect(apolloMutateMock).toBeCalled() + expect(adminCreateContributionMock).toBeCalled() }) }) @@ -275,7 +306,7 @@ describe('CreationFormular', () => { }) it('sends mutation to apollo', () => { - expect(apolloMutateMock).toBeCalled() + expect(adminCreateContributionMock).toBeCalled() }) it('toast success message', () => { diff --git a/admin/src/components/CreationFormular.vue b/admin/src/components/CreationFormular.vue index c6bade1a1..aeaa84cc6 100644 --- a/admin/src/components/CreationFormular.vue +++ b/admin/src/components/CreationFormular.vue @@ -133,14 +133,13 @@ export default { // do we want to reset the memo everytime the month changes? this.text = this.$t('creation_form.creation_for') + ' ' + name.short + ' ' + name.year this.rangeMin = 0 - this.rangeMax = name.creation + this.rangeMax = Number(name.creation) }, submitCreation() { this.$apollo .mutate({ mutation: adminCreateContribution, variables: { - email: this.item.email, creationDate: this.selected.date, amount: Number(this.value), memo: this.text, From d56390bad0396058a4b1e31c7e4f6f216a8cae3a Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 10 Mar 2023 14:22:45 +0100 Subject: [PATCH 240/373] remove creation from admin update contribution --- backend/src/graphql/resolver/ContributionResolver.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 49ab5fd15..b9c73cec5 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -357,8 +357,6 @@ export class ContributionResolver { result.memo = contributionToUpdate.memo result.date = contributionToUpdate.contributionDate - result.creation = await getUserCreation(contributionToUpdate.userId, clientTimezoneOffset) - await EVENT_ADMIN_CONTRIBUTION_UPDATE( contributionToUpdate.userId, contributionToUpdate.id, From 3d41f1d9f36b7e32b4febc9d7864d29bb8339196 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 10 Mar 2023 14:24:34 +0100 Subject: [PATCH 241/373] moderator to moderatorId --- admin/src/pages/Overview.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/admin/src/pages/Overview.spec.js b/admin/src/pages/Overview.spec.js index beb5bc2dd..23585611c 100644 --- a/admin/src/pages/Overview.spec.js +++ b/admin/src/pages/Overview.spec.js @@ -42,7 +42,7 @@ const defaultData = () => { amount: 500, memo: 'Danke für alles', date: new Date(), - moderator: 1, + moderatorId: 1, state: 'PENDING', creation: [500, 500, 500], messagesCount: 0, @@ -64,7 +64,7 @@ const defaultData = () => { amount: 1000000, memo: 'Gut Ergattert', date: new Date(), - moderator: 1, + moderatorId: 1, state: 'PENDING', creation: [500, 500, 500], messagesCount: 0, From d9f5c1e89e252f49aa3f2e06bca5259b74e104b6 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 10 Mar 2023 14:28:27 +0100 Subject: [PATCH 242/373] use moderator id to identify myself --- admin/src/components/Tables/OpenCreationsTable.spec.js | 2 +- admin/src/components/Tables/OpenCreationsTable.vue | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/admin/src/components/Tables/OpenCreationsTable.spec.js b/admin/src/components/Tables/OpenCreationsTable.spec.js index cfb91be0d..8f91aca03 100644 --- a/admin/src/components/Tables/OpenCreationsTable.spec.js +++ b/admin/src/components/Tables/OpenCreationsTable.spec.js @@ -82,7 +82,7 @@ const mocks = { $store: { state: { moderator: { - id: 0, + id: 1, name: 'test moderator', }, }, diff --git a/admin/src/components/Tables/OpenCreationsTable.vue b/admin/src/components/Tables/OpenCreationsTable.vue index 9e0f3c747..9d93eba60 100644 --- a/admin/src/components/Tables/OpenCreationsTable.vue +++ b/admin/src/components/Tables/OpenCreationsTable.vue @@ -147,10 +147,7 @@ export default { }, methods: { myself(item) { - return ( - `${item.firstName} ${item.lastName}` === - `${this.$store.state.moderator.firstName} ${this.$store.state.moderator.lastName}` - ) + return item.userId === this.$store.state.moderator.id }, getStatusIcon(status) { return iconMap[status] ? iconMap[status] : 'default-icon' From d9b19fbfa0699cd0938f4cda8481bc54eb71125c Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 10 Mar 2023 14:44:57 +0100 Subject: [PATCH 243/373] liniting --- admin/src/pages/CreationConfirm.vue | 670 ++++++++++++++-------------- 1 file changed, 335 insertions(+), 335 deletions(-) diff --git a/admin/src/pages/CreationConfirm.vue b/admin/src/pages/CreationConfirm.vue index 92dc01750..b367d1b7f 100644 --- a/admin/src/pages/CreationConfirm.vue +++ b/admin/src/pages/CreationConfirm.vue @@ -83,343 +83,343 @@