From aade850d0edfd81aa972c5b7194e8e909ca70d6c Mon Sep 17 00:00:00 2001 From: Claus-Peter Huebner Date: Mon, 20 Nov 2023 21:32:24 +0100 Subject: [PATCH 01/17] draft: first gms-api request against local gms-server --- backend/.env.dist | 6 +- backend/.env.template | 6 +- backend/src/apis/gms/GmsClient.ts | 80 +++++++++++++++++++ backend/src/apis/gms/model/GmsCommunity.ts | 17 ++++ .../src/apis/gms/model/GmsCommunityProfile.ts | 16 ++++ backend/src/apis/gms/model/GmsRoles.ts | 6 ++ backend/src/apis/gms/model/GmsUser.ts | 18 +++++ backend/src/apis/gms/model/GmsUserAccount.ts | 16 ++++ backend/src/apis/gms/model/GmsUserProfile.ts | 22 +++++ backend/src/config/index.ts | 9 ++- backend/src/federation/validateCommunities.ts | 11 +++ 11 files changed, 204 insertions(+), 3 deletions(-) create mode 100644 backend/src/apis/gms/GmsClient.ts create mode 100644 backend/src/apis/gms/model/GmsCommunity.ts create mode 100644 backend/src/apis/gms/model/GmsCommunityProfile.ts create mode 100644 backend/src/apis/gms/model/GmsRoles.ts create mode 100644 backend/src/apis/gms/model/GmsUser.ts create mode 100644 backend/src/apis/gms/model/GmsUserAccount.ts create mode 100644 backend/src/apis/gms/model/GmsUserProfile.ts diff --git a/backend/.env.dist b/backend/.env.dist index 9844d8c4a..580f7ad2b 100644 --- a/backend/.env.dist +++ b/backend/.env.dist @@ -62,4 +62,8 @@ WEBHOOK_ELOPAGE_SECRET=secret # LOG_LEVEL=info # Federation -FEDERATION_VALIDATE_COMMUNITY_TIMER=60000 \ No newline at end of file +FEDERATION_VALIDATE_COMMUNITY_TIMER=60000 + +# GMS +GMS_HOST=54.176.169.179 +GMS_PORT=3071 diff --git a/backend/.env.template b/backend/.env.template index e79122368..05cec536e 100644 --- a/backend/.env.template +++ b/backend/.env.template @@ -1,5 +1,5 @@ # must match the CONFIG_VERSION.EXPECTED definition in scr/config/index.ts -CONFIG_VERSION=v20.2023-09-19 +CONFIG_VERSION=v21.2023-11-15 # Server JWT_SECRET=$JWT_SECRET @@ -61,3 +61,7 @@ WEBHOOK_ELOPAGE_SECRET=$WEBHOOK_ELOPAGE_SECRET # Federation FEDERATION_VALIDATE_COMMUNITY_TIMER=$FEDERATION_VALIDATE_COMMUNITY_TIMER + +# GMS +GMS_HOST=$GMS_HOST +GMS_PORT=$GMS_PORT diff --git a/backend/src/apis/gms/GmsClient.ts b/backend/src/apis/gms/GmsClient.ts new file mode 100644 index 000000000..d96fbf879 --- /dev/null +++ b/backend/src/apis/gms/GmsClient.ts @@ -0,0 +1,80 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unsafe-argument */ +import axios from 'axios' + +import { CONFIG } from '@/config' +import { LogError } from '@/server/LogError' +import { backendLogger as logger } from '@/server/logger' + +import { GmsCommunity } from './model/GmsCommunity' +import { GmsUser } from './model/GmsUser' + +export async function communityList(): Promise { + const baseUrl = 'http://'.concat(CONFIG.GMS_HOST).concat(':').concat(CONFIG.GMS_PORT).concat('/') + const service = 'community/list?page=1&perPage=20' + const config = { + headers: { + accept: 'application/json', + language: 'en', + timezone: 'UTC', + connection: 'keep-alive', + authorization: + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoiVTJGc2RHVmtYMThuNzllbGJscThDbmxxZ0I2SGxicTZuajlpM2lmV3BTc3pHZFRtOFVTQjJZNWY2bG56elhuSUF0SEwvYVBWdE1uMjA3bnNtWDQ0M21xWVFyd0xJMklHNGtpRkZ3U2FKbVJwRk9VZXNDMXIyRGlta3VLMklwN1lYRTU0c2MzVmlScmMzaHE3djlFNkRabk4xeVMrU1QwRWVZRFI5c09pTDJCdmg4a05DNUc5NTdoZUJzeWlRbXcrNFFmMXFuUk5SNXpWdXhtZEE2WUUrT3hlcS85Y0d6NURyTmhoaHM3MTJZTFcvTmprZGNwdU55dUgxeWxhNEhJZyIsImlhdCI6MTcwMDUxMDg4OX0.WhtNGZc9A_hUfh8CcPjr44kWQWMkKJ7hlYXELOd3yy4', + }, + } + try { + const result = await axios.get(baseUrl.concat(service), config) + logger.debug('GET-Response of community/list:', result) + if (result.status !== 200) { + throw new LogError('HTTP Status Error in community/list:', result.status, result.statusText) + } + logger.debug('responseData:', result.data.responseData.data) + // eslint-disable-next-line @typescript-eslint/no-unsafe-call + const gmsCom = JSON.parse(result.data.responseData.data) + logger.debug('gmsCom:', gmsCom) + // eslint-disable-next-line @typescript-eslint/no-unsafe-return + return gmsCom + } catch (error: any) { + logger.error('Error in Get community/list:', error) + const errMsg: string = error.message + return errMsg + } +} + +export async function userList(): Promise { + const baseUrl = 'http://'.concat(CONFIG.GMS_HOST).concat(':').concat(CONFIG.GMS_PORT).concat('/') + const service = 'community-user/list?page=1&perPage=20' + const config = { + headers: { + accept: 'application/json', + language: 'en', + timezone: 'UTC', + connection: 'keep-alive', + authorization: + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoiVTJGc2RHVmtYMThuNzllbGJscThDbmxxZ0I2SGxicTZuajlpM2lmV3BTc3pHZFRtOFVTQjJZNWY2bG56elhuSUF0SEwvYVBWdE1uMjA3bnNtWDQ0M21xWVFyd0xJMklHNGtpRkZ3U2FKbVJwRk9VZXNDMXIyRGlta3VLMklwN1lYRTU0c2MzVmlScmMzaHE3djlFNkRabk4xeVMrU1QwRWVZRFI5c09pTDJCdmg4a05DNUc5NTdoZUJzeWlRbXcrNFFmMXFuUk5SNXpWdXhtZEE2WUUrT3hlcS85Y0d6NURyTmhoaHM3MTJZTFcvTmprZGNwdU55dUgxeWxhNEhJZyIsImlhdCI6MTcwMDUxMDg4OX0.WhtNGZc9A_hUfh8CcPjr44kWQWMkKJ7hlYXELOd3yy4', + }, + } + try { + const result = await axios.get(baseUrl.concat(service), config) + logger.debug('GET-Response of community/list:', result) + if (result.status !== 200) { + throw new LogError( + 'HTTP Status Error in community-user/list:', + result.status, + result.statusText, + ) + } + logger.debug('responseData:', result.data.responseData.data) + // eslint-disable-next-line @typescript-eslint/no-unsafe-call + const gmsUser = JSON.parse(result.data.responseData.data) + logger.debug('gmsUser:', gmsUser) + // eslint-disable-next-line @typescript-eslint/no-unsafe-return + return gmsUser + } catch (error: any) { + logger.error('Error in Get community-user/list:', error) + const errMsg: string = error.message + return errMsg + } +} diff --git a/backend/src/apis/gms/model/GmsCommunity.ts b/backend/src/apis/gms/model/GmsCommunity.ts new file mode 100644 index 000000000..c979d8ef7 --- /dev/null +++ b/backend/src/apis/gms/model/GmsCommunity.ts @@ -0,0 +1,17 @@ +import { GmsCommunityProfile } from './GmsCommunityProfile' +import { GmsRole } from './GmsRoles' + +export class GmsCommunity { + id: number + uuid: string + communityUuid: string + email: string + countryCode: string + mobile: string + status: number + createdAt: Date + updatedAt: Date + UserProfile: unknown + communityProfile: GmsCommunityProfile + roles: GmsRole[] +} diff --git a/backend/src/apis/gms/model/GmsCommunityProfile.ts b/backend/src/apis/gms/model/GmsCommunityProfile.ts new file mode 100644 index 000000000..a099e2680 --- /dev/null +++ b/backend/src/apis/gms/model/GmsCommunityProfile.ts @@ -0,0 +1,16 @@ +export class GmsCommunityProfile { + name: string + location: { + type: string + coordinates: [number] + } + + address: string + communityId: number + radius: number + description: string + // eslint-disable-next-line camelcase + api_key: string + communityAuthUrl: unknown + profileImage: unknown +} diff --git a/backend/src/apis/gms/model/GmsRoles.ts b/backend/src/apis/gms/model/GmsRoles.ts new file mode 100644 index 000000000..22f4adfb2 --- /dev/null +++ b/backend/src/apis/gms/model/GmsRoles.ts @@ -0,0 +1,6 @@ +export class GmsRole { + code: string + status: number + name: string + Permissions: [unknown] +} diff --git a/backend/src/apis/gms/model/GmsUser.ts b/backend/src/apis/gms/model/GmsUser.ts new file mode 100644 index 000000000..aa1ae4ce4 --- /dev/null +++ b/backend/src/apis/gms/model/GmsUser.ts @@ -0,0 +1,18 @@ +import { GmsRole } from './GmsRoles' +import { GmsUserAccount } from './GmsUserAccount' +import { GmsUserProfile } from './GmsUserProfile' + +export class GmsUser { + id: number + uuid: string + communityUuid: string + email: string + countryCode: string + mobile: string + status: number + createdAt: Date + updatedAt: Date + userProfile: GmsUserProfile + userAccounts: GmsUserAccount[] + roles: GmsRole[] +} diff --git a/backend/src/apis/gms/model/GmsUserAccount.ts b/backend/src/apis/gms/model/GmsUserAccount.ts new file mode 100644 index 000000000..545ed03f3 --- /dev/null +++ b/backend/src/apis/gms/model/GmsUserAccount.ts @@ -0,0 +1,16 @@ +import { Decimal } from 'decimal.js-light' + +export class GmsUserAccount { + name: string + location: { + type: string + coordinates: [Decimal, Decimal] + } + + address: string + radius: number + description: string + // eslint-disable-next-line camelcase + api_key: string + profileImage: unknown +} diff --git a/backend/src/apis/gms/model/GmsUserProfile.ts b/backend/src/apis/gms/model/GmsUserProfile.ts new file mode 100644 index 000000000..de47a1639 --- /dev/null +++ b/backend/src/apis/gms/model/GmsUserProfile.ts @@ -0,0 +1,22 @@ +import { Decimal } from 'decimal.js-light' + +export class GmsUserProfile { + firstName: string + lastName: string + alias: string + type: number + name: string + location: { + type: string + coordinates: [Decimal, Decimal] + } + + accuracy: unknown + address: string + city: string + state: string + country: string + zipCode: string + language: string + profileImage: unknown +} diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 7ad0271ea..645192476 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -19,7 +19,7 @@ const constants = { LOG_LEVEL: process.env.LOG_LEVEL ?? 'info', CONFIG_VERSION: { DEFAULT: 'DEFAULT', - EXPECTED: 'v20.2023-09-19', + EXPECTED: 'v21.2023-11-15', CURRENT: '', }, } @@ -134,6 +134,12 @@ const federation = { process.env.FEDERATION_XCOM_MAXREPEAT_REVERTSENDCOINS ?? 3, } +const gms = { + // koordinates of Illuminz-instance of GMS + GMS_HOST: process.env.GMS_HOST ?? 'localhost', + GMS_PORT: process.env.GMS_PORT ?? '4044', +} + export const CONFIG = { ...constants, ...server, @@ -145,4 +151,5 @@ export const CONFIG = { ...loginServer, ...webhook, ...federation, + ...gms, } diff --git a/backend/src/federation/validateCommunities.ts b/backend/src/federation/validateCommunities.ts index 69b69070a..462595fae 100644 --- a/backend/src/federation/validateCommunities.ts +++ b/backend/src/federation/validateCommunities.ts @@ -12,6 +12,7 @@ import { backendLogger as logger } from '@/server/logger' import { startCommunityAuthentication } from './authenticateCommunities' import { ApiVersionType } from './enum/apiVersionType' +import { communityList, userList } from '@/apis/gms/GmsClient' export async function startValidateCommunities(timerInterval: number): Promise { logger.info( @@ -29,6 +30,16 @@ export async function startValidateCommunities(timerInterval: number): Promise { + // test GMS-Api Client + try { + const gmsComArray = await communityList() + logger.debug('GMS-Community-List:', gmsComArray) + const gmsUserArray = await userList() + logger.debug('GMS-Community-User-List:', gmsUserArray) + } catch (err) { + logger.error('Error in GMS-API:', err) + } + const dbFederatedCommunities: DbFederatedCommunity[] = await DbFederatedCommunity.createQueryBuilder() .where({ foreign: true, verifiedAt: IsNull() }) From fe5234806abe23add471bd97082005d2a3865bc8 Mon Sep 17 00:00:00 2001 From: Claus-Peter Huebner Date: Fri, 24 Nov 2023 02:14:38 +0100 Subject: [PATCH 02/17] first draft seeding users to gms --- backend/package.json | 1 + backend/src/apis/gms/GmsClient.ts | 66 ++++++++ backend/src/apis/gms/model/GmsEnums.ts | 37 +++++ backend/src/apis/gms/model/GmsUser.ts | 136 ++++++++++++++++- backend/src/apis/gms/model/GmsUserProfile.ts | 14 +- backend/src/config/index.ts | 2 +- backend/src/seeds/gmsUsers.ts | 91 +++++++++++ backend/src/util/communityUser.ts | 4 + .../Community.ts | 66 ++++++++ .../0075-introduce_gms_registration/User.ts | 144 ++++++++++++++++++ .../UserContact.ts | 93 +++++++++++ database/entity/Community.ts | 2 +- database/entity/User.ts | 2 +- database/entity/UserContact.ts | 2 +- .../0075-introduce_gms_registration.ts | 66 ++++++++ dht-node/src/config/index.ts | 2 +- federation/src/config/index.ts | 2 +- 17 files changed, 710 insertions(+), 20 deletions(-) create mode 100644 backend/src/apis/gms/model/GmsEnums.ts create mode 100644 backend/src/seeds/gmsUsers.ts create mode 100644 database/entity/0075-introduce_gms_registration/Community.ts create mode 100644 database/entity/0075-introduce_gms_registration/User.ts create mode 100644 database/entity/0075-introduce_gms_registration/UserContact.ts create mode 100644 database/migrations/0075-introduce_gms_registration.ts diff --git a/backend/package.json b/backend/package.json index 1f4ea67af..8140bdd3d 100644 --- a/backend/package.json +++ b/backend/package.json @@ -16,6 +16,7 @@ "test": "cross-env TZ=UTC NODE_ENV=development jest --runInBand --forceExit --detectOpenHandles", "seed": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/seeds/index.ts", "klicktipp": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/util/executeKlicktipp.ts", + "gmsusers": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/seeds/gmsUsers.ts", "locales": "scripts/sort.sh" }, "dependencies": { diff --git a/backend/src/apis/gms/GmsClient.ts b/backend/src/apis/gms/GmsClient.ts index d96fbf879..ec3298267 100644 --- a/backend/src/apis/gms/GmsClient.ts +++ b/backend/src/apis/gms/GmsClient.ts @@ -78,3 +78,69 @@ export async function userList(): Promise { return errMsg } } + +export async function userByUuid(uuid: string): Promise { + const baseUrl = 'http://'.concat(CONFIG.GMS_HOST).concat(':').concat(CONFIG.GMS_PORT).concat('/') + const service = 'community-user/list?page=1&perPage=20' + const config = { + headers: { + accept: 'application/json', + language: 'en', + timezone: 'UTC', + connection: 'keep-alive', + authorization: + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoiVTJGc2RHVmtYMThuNzllbGJscThDbmxxZ0I2SGxicTZuajlpM2lmV3BTc3pHZFRtOFVTQjJZNWY2bG56elhuSUF0SEwvYVBWdE1uMjA3bnNtWDQ0M21xWVFyd0xJMklHNGtpRkZ3U2FKbVJwRk9VZXNDMXIyRGlta3VLMklwN1lYRTU0c2MzVmlScmMzaHE3djlFNkRabk4xeVMrU1QwRWVZRFI5c09pTDJCdmg4a05DNUc5NTdoZUJzeWlRbXcrNFFmMXFuUk5SNXpWdXhtZEE2WUUrT3hlcS85Y0d6NURyTmhoaHM3MTJZTFcvTmprZGNwdU55dUgxeWxhNEhJZyIsImlhdCI6MTcwMDUxMDg4OX0.WhtNGZc9A_hUfh8CcPjr44kWQWMkKJ7hlYXELOd3yy4', + }, + } + try { + const result = await axios.get(baseUrl.concat(service), config) + logger.debug('GET-Response of community/list:', result) + if (result.status !== 200) { + throw new LogError( + 'HTTP Status Error in community-user/list:', + result.status, + result.statusText, + ) + } + logger.debug('responseData:', result.data.responseData.data) + // eslint-disable-next-line @typescript-eslint/no-unsafe-call + const gmsUser = JSON.parse(result.data.responseData.data) + logger.debug('gmsUser:', gmsUser) + // eslint-disable-next-line @typescript-eslint/no-unsafe-return + return gmsUser + } catch (error: any) { + logger.error('Error in Get community-user/list:', error) + const errMsg: string = error.message + return errMsg + } +} + +export async function createGmsUser(apiKey: string, user: GmsUser): Promise { + const baseUrl = 'http://'.concat(CONFIG.GMS_HOST).concat(':').concat(CONFIG.GMS_PORT).concat('/') + const service = 'community-user' + const config = { + headers: { + accept: 'application/json', + language: 'en', + timezone: 'UTC', + connection: 'keep-alive', + authorization: apiKey, + // 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoiVTJGc2RHVmtYMThuNzllbGJscThDbmxxZ0I2SGxicTZuajlpM2lmV3BTc3pHZFRtOFVTQjJZNWY2bG56elhuSUF0SEwvYVBWdE1uMjA3bnNtWDQ0M21xWVFyd0xJMklHNGtpRkZ3U2FKbVJwRk9VZXNDMXIyRGlta3VLMklwN1lYRTU0c2MzVmlScmMzaHE3djlFNkRabk4xeVMrU1QwRWVZRFI5c09pTDJCdmg4a05DNUc5NTdoZUJzeWlRbXcrNFFmMXFuUk5SNXpWdXhtZEE2WUUrT3hlcS85Y0d6NURyTmhoaHM3MTJZTFcvTmprZGNwdU55dUgxeWxhNEhJZyIsImlhdCI6MTcwMDUxMDg4OX0.WhtNGZc9A_hUfh8CcPjr44kWQWMkKJ7hlYXELOd3yy4', + }, + } + try { + const result = await axios.post(baseUrl.concat(service), user, config) + logger.debug('POST-Response of community-user:', result) + if (result.status !== 200) { + throw new LogError('HTTP Status Error in community-user:', result.status, result.statusText) + } + logger.debug('responseData:', result.data.responseData.data) + // eslint-disable-next-line @typescript-eslint/no-unsafe-call + const gmsUser = JSON.parse(result.data.responseData) + logger.debug('gmsUser:', gmsUser) + return true + } catch (error: any) { + logger.error('Error in Get community-user:', error) + throw new LogError(error.message) + } +} diff --git a/backend/src/apis/gms/model/GmsEnums.ts b/backend/src/apis/gms/model/GmsEnums.ts new file mode 100644 index 000000000..00662c47c --- /dev/null +++ b/backend/src/apis/gms/model/GmsEnums.ts @@ -0,0 +1,37 @@ +import { registerEnumType } from 'type-graphql' + +export enum GmsPublishNameType { + GMS_PUBLISH_NAME_NOTHING = 0, + GMS_PUBLISH_NAME_INITIALS = 1, + GMS_PUBLISH_NAME_FIRST = 2, + GMS_PUBLISH_NAME_FIRST_INITIAL = 3, + GMS_PUBLISH_NAME_FULL = 4, +} + +registerEnumType(GmsPublishNameType, { + name: 'GmsPublishNameType', // this one is mandatory + description: 'Type of name publishing', // this one is optional +}) + +export enum GmsPublishPhoneType { + GMS_PUBLISH_PHONE_NOTHING = 0, + GMS_PUBLISH_PHONE_COUNTRY = 1, + GMS_PUBLISH_PHONE_FULL = 2, +} + +registerEnumType(GmsPublishPhoneType, { + name: 'GmsPublishPhoneType', // this one is mandatory + description: 'Type of Phone publishing', // this one is optional +}) + +export enum GmsPublishPostType { + GMS_PUBLISH_POST_NOTHING = 0, + GMS_PUBLISH_POST_COUNTRY = 1, + GMS_PUBLISH_POST_CITY = 2, + GMS_PUBLISH_POST_FULL = 3, +} + +registerEnumType(GmsPublishPostType, { + name: 'GmsPublishPostType', // this one is mandatory + description: 'Type of name publishing', // this one is optional +}) diff --git a/backend/src/apis/gms/model/GmsUser.ts b/backend/src/apis/gms/model/GmsUser.ts index aa1ae4ce4..84c7041d8 100644 --- a/backend/src/apis/gms/model/GmsUser.ts +++ b/backend/src/apis/gms/model/GmsUser.ts @@ -1,18 +1,140 @@ +import { User as dbUser } from '@entity/User' + +import { GmsPublishNameType, GmsPublishPhoneType, GmsPublishPostType } from './GmsEnums' import { GmsRole } from './GmsRoles' import { GmsUserAccount } from './GmsUserAccount' import { GmsUserProfile } from './GmsUserProfile' export class GmsUser { + constructor(user: dbUser) { + this.userUuid = user.gradidoID + // this.communityUuid = user.communityUuid + this.email = this.getGmsEmail(user) + this.countryCode = this.getGmsCountryCode(user) + this.mobile = this.getGmsPhone(user) + this.firstName = this.getGmsFirstName(user) + this.lastName = this.getGmsLastName(user) + this.alias = user.alias ? user.alias : undefined + this.address = this.getGmsAddress(user) + this.zipCode = this.getGmsZipCode(user) + this.city = this.getGmsCity(user) + this.country = this.getGmsCountry(user) + this.type = 1 + this.location = null + } + id: number - uuid: string + userUuid: string communityUuid: string - email: string - countryCode: string - mobile: string + email: string | undefined + countryCode: string | undefined + mobile: string | undefined status: number createdAt: Date updatedAt: Date - userProfile: GmsUserProfile - userAccounts: GmsUserAccount[] - roles: GmsRole[] + firstName: string | undefined + lastName: string | undefined + alias: string | undefined + type: number + address: string | undefined + city: string | undefined + state: string + country: string | undefined + zipCode: string | undefined + language: string + location: unknown + + private getGmsFirstName(user: dbUser): string | undefined { + if ( + user.gmsAllowed && + (user.gmsPublishName === GmsPublishNameType.GMS_PUBLISH_NAME_FIRST || + user.gmsPublishName === GmsPublishNameType.GMS_PUBLISH_NAME_FULL) + ) { + return user.firstName + } + if ( + user.gmsAllowed && + (user.gmsPublishName === GmsPublishNameType.GMS_PUBLISH_NAME_FIRST_INITIAL || + user.gmsPublishName === GmsPublishNameType.GMS_PUBLISH_NAME_INITIALS) + ) { + return user.firstName.substring(0, 1) + '.' + } + } + + private getGmsLastName(user: dbUser): string | undefined { + if (user.gmsAllowed && user.gmsPublishName === GmsPublishNameType.GMS_PUBLISH_NAME_FULL) { + return user.lastName + } + if ( + user.gmsAllowed && + (user.gmsPublishName === GmsPublishNameType.GMS_PUBLISH_NAME_FIRST_INITIAL || + user.gmsPublishName === GmsPublishNameType.GMS_PUBLISH_NAME_INITIALS) + ) { + return user.lastName.substring(0, 1) + '.' + } + } + + private getGmsEmail(user: dbUser): string | undefined { + if (user.gmsAllowed && user.emailContact.gmsPublishEmail === true) { + return user.emailContact.email + } + } + + private getGmsCountryCode(user: dbUser): string | undefined { + if ( + user.gmsAllowed && + (user.emailContact.gmsPublishPhone === GmsPublishPhoneType.GMS_PUBLISH_PHONE_COUNTRY || + user.emailContact.gmsPublishPhone === GmsPublishPhoneType.GMS_PUBLISH_PHONE_FULL) + ) { + return user.emailContact.countryCode + } + } + + private getGmsPhone(user: dbUser): string | undefined { + if ( + user.gmsAllowed && + user.emailContact.gmsPublishPhone === GmsPublishPhoneType.GMS_PUBLISH_PHONE_FULL + ) { + return user.emailContact.phone + } + } + + private getGmsAddress(user: dbUser): string | undefined { + if ( + user.gmsAllowed && + user.emailContact.gmsPublishPost === GmsPublishPostType.GMS_PUBLISH_POST_FULL + ) { + return user.emailContact.address + } + } + + private getGmsZipCode(user: dbUser): string | undefined { + if ( + user.gmsAllowed && + (user.emailContact.gmsPublishPost === GmsPublishPostType.GMS_PUBLISH_POST_CITY || + user.emailContact.gmsPublishPost === GmsPublishPostType.GMS_PUBLISH_POST_FULL) + ) { + return user.emailContact.zipCode + } + } + + private getGmsCity(user: dbUser): string | undefined { + if ( + user.gmsAllowed && + (user.emailContact.gmsPublishPost === GmsPublishPostType.GMS_PUBLISH_POST_CITY || + user.emailContact.gmsPublishPost === GmsPublishPostType.GMS_PUBLISH_POST_FULL) + ) { + return user.emailContact.city + } + } + + private getGmsCountry(user: dbUser): string | undefined { + if ( + user.gmsAllowed && + (user.emailContact.gmsPublishPost === GmsPublishPostType.GMS_PUBLISH_POST_COUNTRY || + user.emailContact.gmsPublishPost === GmsPublishPostType.GMS_PUBLISH_POST_FULL) + ) { + return user.emailContact.country + } + } } diff --git a/backend/src/apis/gms/model/GmsUserProfile.ts b/backend/src/apis/gms/model/GmsUserProfile.ts index de47a1639..eb0b2dccf 100644 --- a/backend/src/apis/gms/model/GmsUserProfile.ts +++ b/backend/src/apis/gms/model/GmsUserProfile.ts @@ -1,22 +1,22 @@ import { Decimal } from 'decimal.js-light' export class GmsUserProfile { - firstName: string - lastName: string + firstName: string | undefined + lastName: string | undefined alias: string type: number - name: string + name: string | undefined location: { type: string coordinates: [Decimal, Decimal] } accuracy: unknown - address: string - city: string + address: string | undefined + city: string | undefined state: string - country: string - zipCode: string + country: string | undefined + zipCode: string | undefined language: string profileImage: unknown } diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 645192476..d28256119 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -12,7 +12,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0074-insert_communityuuid in_existing_users', + DB_VERSION: '0075-introduce_gms_registration', 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/seeds/gmsUsers.ts b/backend/src/seeds/gmsUsers.ts new file mode 100644 index 000000000..c979ed29a --- /dev/null +++ b/backend/src/seeds/gmsUsers.ts @@ -0,0 +1,91 @@ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ + +import { entities } from '@entity/index' +import { User as DbUser } from '@entity/User' +import { createTestClient } from 'apollo-server-testing' + +import { createGmsUser } from '@/apis/gms/GmsClient' +import { GmsUser } from '@/apis/gms/model/GmsUser' +import { CONFIG } from '@/config' +import { getHomeCommunity } from '@/graphql/resolver/util/communities' +import { createServer } from '@/server/createServer' +import { LogError } from '@/server/LogError' +import { backendLogger as logger } from '@/server/logger' + +CONFIG.EMAIL = false + +const context = { + token: '', + setHeaders: { + push: (value: { key: string; value: string }): void => { + context.token = value.value + }, + // eslint-disable-next-line @typescript-eslint/no-empty-function + forEach: (): void => {}, + }, + clientTimezoneOffset: 0, +} + +export const cleanDB = async () => { + // this only works as long we do not have foreign key constraints + for (const entity of entities) { + await resetEntity(entity) + } +} + +const resetEntity = async (entity: any) => { + const items = await entity.find({ withDeleted: true }) + if (items.length > 0) { + const ids = items.map((e: any) => e.id) + await entity.delete(ids) + } +} + +const run = async () => { + const server = await createServer(context) + const seedClient = createTestClient(server.apollo) + const { con } = server + + const homeCom = await getHomeCommunity() + if (homeCom.gmsApiKey === null) { + throw new LogError('HomeCommunity needs GMS-ApiKey to publish user data to GMS.') + } + // read the ids of all local users, which are still not gms registered + const userIds = await DbUser.query( + 'SELECT `id` from `users` `u` where `u`.`foreign` = false and `deleted_at` is null and `gms_registered` = false', + ) + logger.debug('userIds:', userIds) + + for (const idStr of userIds) { + logger.debug('Id:', idStr.id) + const user = await DbUser.findOne({ + where: { id: idStr.id }, + relations: ['emailContact'], + }) + if (user) { + logger.debug('found local User:', user) + const gmsUser = new GmsUser(user) + try { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + if (await createGmsUser(homeCom.gmsApiKey, gmsUser)) { + logger.debug('GMS user published successfully:', gmsUser) + user.gmsRegistered = true + user.gmsRegisteredAt = new Date() + await DbUser.save(user) + logger.debug('mark user as gms published:', user) + } + } catch (err) { + logger.warn('publishing user fails with ', err) + } + } + } + logger.info('##gms## publishing all local users successful...') + + await con.close() +} + +void run() diff --git a/backend/src/util/communityUser.ts b/backend/src/util/communityUser.ts index bad06f201..a0c4bf681 100644 --- a/backend/src/util/communityUser.ts +++ b/backend/src/util/communityUser.ts @@ -50,6 +50,10 @@ const communityDbUser: dbUser = { }, foreign: false, communityUuid: '55555555-4444-4333-2222-11111111', + gmsPublishName: 0, + gmsAllowed: false, + gmsRegistered: false, + gmsRegisteredAt: null, } const communityUser = new User(communityDbUser) diff --git a/database/entity/0075-introduce_gms_registration/Community.ts b/database/entity/0075-introduce_gms_registration/Community.ts new file mode 100644 index 000000000..89c31763f --- /dev/null +++ b/database/entity/0075-introduce_gms_registration/Community.ts @@ -0,0 +1,66 @@ +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: true }) + foreign: boolean + + @Column({ name: 'url', length: 255, nullable: false }) + url: string + + @Column({ name: 'public_key', type: 'binary', length: 32, nullable: false }) + publicKey: Buffer + + @Column({ name: 'private_key', type: 'binary', length: 64, nullable: true }) + privateKey: Buffer | null + + @Column({ + name: 'community_uuid', + type: 'char', + length: 36, + nullable: true, + collation: 'utf8mb4_unicode_ci', + }) + communityUuid: string | null + + @Column({ name: 'authenticated_at', type: 'datetime', nullable: true }) + authenticatedAt: Date | null + + @Column({ name: 'name', type: 'varchar', length: 40, nullable: true }) + name: string | null + + @Column({ name: 'description', type: 'varchar', length: 255, nullable: true }) + description: string | null + + @CreateDateColumn({ name: 'creation_date', type: 'datetime', nullable: true }) + creationDate: Date | null + + @Column({ name: 'gms_api_key', type: 'varchar', length: 512, nullable: true, default: null }) + gmsApiKey: string | null + + @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/0075-introduce_gms_registration/User.ts b/database/entity/0075-introduce_gms_registration/User.ts new file mode 100644 index 000000000..edcdd1257 --- /dev/null +++ b/database/entity/0075-introduce_gms_registration/User.ts @@ -0,0 +1,144 @@ +import { + BaseEntity, + Entity, + PrimaryGeneratedColumn, + Column, + DeleteDateColumn, + OneToMany, + JoinColumn, + OneToOne, +} from 'typeorm' +import { Contribution } from '../Contribution' +import { ContributionMessage } from '../ContributionMessage' +import { UserContact } from '../UserContact' +import { UserRole } from '../UserRole' + +@Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' }) +export class User extends BaseEntity { + @PrimaryGeneratedColumn('increment', { unsigned: true }) + id: number + + @Column({ type: 'bool', default: false }) + foreign: boolean + + @Column({ + name: 'gradido_id', + length: 36, + nullable: false, + collation: 'utf8mb4_unicode_ci', + }) + gradidoID: string + + @Column({ + name: 'community_uuid', + type: 'char', + length: 36, + nullable: true, + collation: 'utf8mb4_unicode_ci', + }) + communityUuid: string + + @Column({ + name: 'alias', + length: 20, + nullable: true, + default: null, + collation: 'utf8mb4_unicode_ci', + }) + alias: string + + @OneToOne(() => UserContact, (emailContact: UserContact) => emailContact.user) + @JoinColumn({ name: 'email_id' }) + emailContact: UserContact + + @Column({ name: 'email_id', type: 'int', unsigned: true, nullable: true, default: null }) + emailId: number | null + + @Column({ + name: 'first_name', + length: 255, + nullable: true, + default: null, + collation: 'utf8mb4_unicode_ci', + }) + firstName: string + + @Column({ + name: 'last_name', + length: 255, + nullable: true, + default: null, + collation: 'utf8mb4_unicode_ci', + }) + lastName: string + + @Column({ name: 'gms_publish_name', type: 'int', unsigned: true, nullable: false, default: 0 }) + gmsPublishName: number + + @Column({ name: 'created_at', default: () => 'CURRENT_TIMESTAMP(3)', nullable: false }) + createdAt: Date + + @DeleteDateColumn({ name: 'deleted_at', nullable: true }) + deletedAt: Date | null + + @Column({ type: 'bigint', default: 0, unsigned: true }) + password: BigInt + + @Column({ + name: 'password_encryption_type', + type: 'int', + unsigned: true, + nullable: false, + default: 0, + }) + passwordEncryptionType: number + + @Column({ length: 4, default: 'de', collation: 'utf8mb4_unicode_ci', nullable: false }) + language: string + + @Column({ type: 'bool', default: false }) + hideAmountGDD: boolean + + @Column({ type: 'bool', default: false }) + hideAmountGDT: boolean + + @OneToMany(() => UserRole, (userRole) => userRole.user) + @JoinColumn({ name: 'user_id' }) + userRoles: UserRole[] + + @Column({ name: 'referrer_id', type: 'int', unsigned: true, nullable: true, default: null }) + referrerId?: number | null + + @Column({ + name: 'contribution_link_id', + type: 'int', + unsigned: true, + nullable: true, + default: null, + }) + contributionLinkId?: number | null + + @Column({ name: 'publisher_id', default: 0 }) + publisherId: number + + @Column({ name: 'gms_allowed', type: 'bool', default: true }) + gmsAllowed: boolean + + @Column({ name: 'gms_registered', type: 'bool', default: false }) + gmsRegistered: boolean + + @Column({ name: 'gms_registered_at', type: 'datetime', default: null, nullable: true }) + gmsRegisteredAt: Date | null + + @OneToMany(() => Contribution, (contribution) => contribution.user) + @JoinColumn({ name: 'user_id' }) + contributions?: Contribution[] + + @OneToMany(() => ContributionMessage, (message) => message.user) + @JoinColumn({ name: 'user_id' }) + messages?: ContributionMessage[] + + @OneToMany(() => UserContact, (userContact: UserContact) => userContact.user) + @JoinColumn({ name: 'user_id' }) + userContacts?: UserContact[] +} diff --git a/database/entity/0075-introduce_gms_registration/UserContact.ts b/database/entity/0075-introduce_gms_registration/UserContact.ts new file mode 100644 index 000000000..a3d0a8f52 --- /dev/null +++ b/database/entity/0075-introduce_gms_registration/UserContact.ts @@ -0,0 +1,93 @@ +import { + BaseEntity, + Entity, + PrimaryGeneratedColumn, + Column, + DeleteDateColumn, + OneToOne, +} from 'typeorm' +import { User } from '../User' + +@Entity('user_contacts', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' }) +export class UserContact extends BaseEntity { + @PrimaryGeneratedColumn('increment', { unsigned: true }) + id: number + + @Column({ + name: 'type', + length: 100, + nullable: true, + default: null, + collation: 'utf8mb4_unicode_ci', + }) + type: string + + @OneToOne(() => User, (user) => user.emailContact) + user: User + + @Column({ name: 'user_id', type: 'int', unsigned: true, nullable: false }) + userId: number + + @Column({ length: 255, unique: true, nullable: false, collation: 'utf8mb4_unicode_ci' }) + email: string + + @Column({ name: 'gms_publish_email', type: 'bool', nullable: false, default: false }) + gmsPublishEmail: boolean + + @Column({ name: 'email_verification_code', type: 'bigint', unsigned: true, unique: true }) + emailVerificationCode: string + + @Column({ name: 'email_opt_in_type_id' }) + emailOptInTypeId: number + + @Column({ name: 'email_resend_count' }) + emailResendCount: number + + @Column({ name: 'email_checked', type: 'bool', nullable: false, default: false }) + emailChecked: boolean + + @Column({ + name: 'country_code', + length: 255, + unique: false, + nullable: true, + collation: 'utf8mb4_unicode_ci', + }) + countryCode: string + + @Column({ length: 255, unique: false, nullable: true, collation: 'utf8mb4_unicode_ci' }) + phone: string + + @Column({ name: 'gms_publish_phone', type: 'int', unsigned: true, nullable: false, default: 0 }) + gmsPublishPhone: number + + @Column({ length: 255, unique: false, nullable: true, collation: 'utf8mb4_unicode_ci' }) + address: string + + @Column({ length: 255, unique: false, nullable: true, collation: 'utf8mb4_unicode_ci' }) + city: string + + @Column({ + name: 'zip_code', + length: 255, + unique: false, + nullable: true, + collation: 'utf8mb4_unicode_ci', + }) + zipCode: string + + @Column({ length: 255, unique: false, nullable: true, collation: 'utf8mb4_unicode_ci' }) + country: string + + @Column({ name: 'gms_publish_post', type: 'int', unsigned: true, nullable: false, default: 0 }) + gmsPublishPost: number + + @Column({ name: 'created_at', default: () => 'CURRENT_TIMESTAMP', nullable: false }) + createdAt: Date + + @Column({ name: 'updated_at', nullable: true, default: null, type: 'datetime' }) + updatedAt: Date | null + + @DeleteDateColumn({ name: 'deleted_at', nullable: true }) + deletedAt: Date | null +} diff --git a/database/entity/Community.ts b/database/entity/Community.ts index d398cf584..26a989a6a 100644 --- a/database/entity/Community.ts +++ b/database/entity/Community.ts @@ -1 +1 @@ -export { Community } from './0068-community_tables_public_key_length/Community' +export { Community } from './0075-introduce_gms_registration/Community' diff --git a/database/entity/User.ts b/database/entity/User.ts index 21785ee9c..e7e42b78c 100644 --- a/database/entity/User.ts +++ b/database/entity/User.ts @@ -1 +1 @@ -export { User } from './0073-introduce_foreign_user_in_users_table/User' +export { User } from './0075-introduce_gms_registration/User' diff --git a/database/entity/UserContact.ts b/database/entity/UserContact.ts index 17d4575b0..97f9fada1 100644 --- a/database/entity/UserContact.ts +++ b/database/entity/UserContact.ts @@ -1 +1 @@ -export { UserContact } from './0057-clear_old_password_junk/UserContact' +export { UserContact } from './0075-introduce_gms_registration/UserContact' diff --git a/database/migrations/0075-introduce_gms_registration.ts b/database/migrations/0075-introduce_gms_registration.ts new file mode 100644 index 000000000..6de55333f --- /dev/null +++ b/database/migrations/0075-introduce_gms_registration.ts @@ -0,0 +1,66 @@ +/* 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 `users` MODIFY COLUMN `foreign` tinyint(1) NOT NULL DEFAULT 0 AFTER `id`;', + ) + await queryFn( + 'ALTER TABLE `users` ADD COLUMN IF NOT EXISTS `gms_publish_name` int unsigned NOT NULL DEFAULT 3 AFTER `last_name`;', // COMMENT '0:nothing, 1:initials only, 2:firstName only, 3:firstName + Initial of LastName, 4:fullName' + ) + await queryFn( + 'ALTER TABLE `users` ADD COLUMN IF NOT EXISTS `gms_allowed` tinyint(1) NOT NULL DEFAULT 1;', + ) + await queryFn( + 'ALTER TABLE `users` ADD COLUMN IF NOT EXISTS `gms_registered` tinyint(1) NOT NULL DEFAULT 0;', + ) + await queryFn( + 'ALTER TABLE `users` ADD COLUMN IF NOT EXISTS `gms_registered_at` datetime(3) DEFAULT NULL NULL;', + ) + await queryFn( + 'ALTER TABLE `user_contacts` ADD COLUMN IF NOT EXISTS `gms_publish_email` tinyint(1) NOT NULL DEFAULT 0 AFTER `email_checked`;', // COMMENT '0:nothing, 1:email' + ) + await queryFn( + 'ALTER TABLE `user_contacts` ADD COLUMN IF NOT EXISTS `country_code` varchar(255) DEFAULT NULL NULL AFTER `gms_publish_email`;', + ) + await queryFn( + 'ALTER TABLE `user_contacts` ADD COLUMN IF NOT EXISTS `gms_publish_phone` int unsigned NOT NULL DEFAULT 0 AFTER `phone`;', // COMMENT '0:nothing, 1:country_code only, 2:complet phone number' + ) + await queryFn( + 'ALTER TABLE `user_contacts` ADD COLUMN IF NOT EXISTS `address` varchar(255) DEFAULT NULL NULL AFTER `gms_publish_phone`;', + ) + await queryFn( + 'ALTER TABLE `user_contacts` ADD COLUMN IF NOT EXISTS `city` varchar(255) DEFAULT NULL NULL AFTER `address`;', + ) + await queryFn( + 'ALTER TABLE `user_contacts` ADD COLUMN IF NOT EXISTS `zip_code` varchar(255) DEFAULT NULL NULL AFTER `city`;', + ) + await queryFn( + 'ALTER TABLE `user_contacts` ADD COLUMN IF NOT EXISTS `country` varchar(255) DEFAULT NULL NULL AFTER `zip_code`;', + ) + await queryFn( + 'ALTER TABLE `user_contacts` ADD COLUMN IF NOT EXISTS `gms_publish_post` int unsigned NOT NULL DEFAULT 0 AFTER `country`;', // COMMENT '0:nothing, 1:country, 2:city, 3: detailed address' + ) + await queryFn( + 'ALTER TABLE `communities` ADD COLUMN IF NOT EXISTS `gms_api_key` varchar(512) DEFAULT NULL NULL AFTER `description`;', + ) +} + +export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn( + 'ALTER TABLE `users` MODIFY COLUMN `foreign` tinyint(4) NOT NULL DEFAULT 0 AFTER `id`;', + ) + await queryFn('ALTER TABLE `users` DROP COLUMN IF EXISTS `gms_publish_name`;') + await queryFn('ALTER TABLE `users` DROP COLUMN IF EXISTS `gms_allowed`;') + await queryFn('ALTER TABLE `users` DROP COLUMN IF EXISTS `gms_registered`;') + await queryFn('ALTER TABLE `users` DROP COLUMN IF EXISTS `gms_registered_at`;') + await queryFn('ALTER TABLE `user_contacts` DROP COLUMN IF EXISTS `gms_publish_email`;') + await queryFn('ALTER TABLE `user_contacts` DROP COLUMN IF EXISTS `country_code`;') + await queryFn('ALTER TABLE `user_contacts` DROP COLUMN IF EXISTS `gms_publish_phone`;') + await queryFn('ALTER TABLE `user_contacts` DROP COLUMN IF EXISTS `address`;') + await queryFn('ALTER TABLE `user_contacts` DROP COLUMN IF EXISTS `city`;') + await queryFn('ALTER TABLE `user_contacts` DROP COLUMN IF EXISTS `zip_code`;') + await queryFn('ALTER TABLE `user_contacts` DROP COLUMN IF EXISTS `country`;') + await queryFn('ALTER TABLE `user_contacts` DROP COLUMN IF EXISTS `gms_publish_post`;') + await queryFn('ALTER TABLE `communities` DROP COLUMN IF EXISTS `gms_api_key`;') +} diff --git a/dht-node/src/config/index.ts b/dht-node/src/config/index.ts index 7aed88ccd..21ff29000 100644 --- a/dht-node/src/config/index.ts +++ b/dht-node/src/config/index.ts @@ -4,7 +4,7 @@ import dotenv from 'dotenv' dotenv.config() const constants = { - DB_VERSION: '0074-insert_communityuuid in_existing_users', + DB_VERSION: '0075-introduce_gms_registration', 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 2770ada06..8e0f6e083 100644 --- a/federation/src/config/index.ts +++ b/federation/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0074-insert_communityuuid in_existing_users', + DB_VERSION: '0075-introduce_gms_registration', 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 55671eb81aa510b1a770205089808bc3411f8a39 Mon Sep 17 00:00:00 2001 From: Claus-Peter Huebner Date: Tue, 28 Nov 2023 23:50:52 +0100 Subject: [PATCH 03/17] gmsuserList as new yarn-script --- backend/package.json | 1 + backend/src/apis/gms/model/GmsUser.ts | 7 +- backend/src/federation/validateCommunities.ts | 11 ---- backend/src/seeds/gmsUserList.ts | 65 +++++++++++++++++++ 4 files changed, 68 insertions(+), 16 deletions(-) create mode 100644 backend/src/seeds/gmsUserList.ts diff --git a/backend/package.json b/backend/package.json index 8140bdd3d..14bd67d9f 100644 --- a/backend/package.json +++ b/backend/package.json @@ -17,6 +17,7 @@ "seed": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/seeds/index.ts", "klicktipp": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/util/executeKlicktipp.ts", "gmsusers": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/seeds/gmsUsers.ts", + "gmsuserList": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/seeds/gmsUserList.ts", "locales": "scripts/sort.sh" }, "dependencies": { diff --git a/backend/src/apis/gms/model/GmsUser.ts b/backend/src/apis/gms/model/GmsUser.ts index 84c7041d8..537cb40c2 100644 --- a/backend/src/apis/gms/model/GmsUser.ts +++ b/backend/src/apis/gms/model/GmsUser.ts @@ -1,9 +1,6 @@ import { User as dbUser } from '@entity/User' import { GmsPublishNameType, GmsPublishPhoneType, GmsPublishPostType } from './GmsEnums' -import { GmsRole } from './GmsRoles' -import { GmsUserAccount } from './GmsUserAccount' -import { GmsUserProfile } from './GmsUserProfile' export class GmsUser { constructor(user: dbUser) { @@ -15,11 +12,11 @@ export class GmsUser { this.firstName = this.getGmsFirstName(user) this.lastName = this.getGmsLastName(user) this.alias = user.alias ? user.alias : undefined - this.address = this.getGmsAddress(user) + this.address = this.getGmsAddress(user) ?? 'Deutschland' this.zipCode = this.getGmsZipCode(user) this.city = this.getGmsCity(user) this.country = this.getGmsCountry(user) - this.type = 1 + this.type = 2 this.location = null } diff --git a/backend/src/federation/validateCommunities.ts b/backend/src/federation/validateCommunities.ts index 462595fae..69b69070a 100644 --- a/backend/src/federation/validateCommunities.ts +++ b/backend/src/federation/validateCommunities.ts @@ -12,7 +12,6 @@ import { backendLogger as logger } from '@/server/logger' import { startCommunityAuthentication } from './authenticateCommunities' import { ApiVersionType } from './enum/apiVersionType' -import { communityList, userList } from '@/apis/gms/GmsClient' export async function startValidateCommunities(timerInterval: number): Promise { logger.info( @@ -30,16 +29,6 @@ export async function startValidateCommunities(timerInterval: number): Promise { - // test GMS-Api Client - try { - const gmsComArray = await communityList() - logger.debug('GMS-Community-List:', gmsComArray) - const gmsUserArray = await userList() - logger.debug('GMS-Community-User-List:', gmsUserArray) - } catch (err) { - logger.error('Error in GMS-API:', err) - } - const dbFederatedCommunities: DbFederatedCommunity[] = await DbFederatedCommunity.createQueryBuilder() .where({ foreign: true, verifiedAt: IsNull() }) diff --git a/backend/src/seeds/gmsUserList.ts b/backend/src/seeds/gmsUserList.ts new file mode 100644 index 000000000..009c097a7 --- /dev/null +++ b/backend/src/seeds/gmsUserList.ts @@ -0,0 +1,65 @@ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ + +import { entities } from '@entity/index' +import { User as DbUser } from '@entity/User' +import { createTestClient } from 'apollo-server-testing' + +import { communityList, createGmsUser, userList } from '@/apis/gms/GmsClient' +import { GmsUser } from '@/apis/gms/model/GmsUser' +import { CONFIG } from '@/config' +import { getHomeCommunity } from '@/graphql/resolver/util/communities' +import { createServer } from '@/server/createServer' +import { LogError } from '@/server/LogError' +import { backendLogger as logger } from '@/server/logger' + +CONFIG.EMAIL = false + +const context = { + token: '', + setHeaders: { + push: (value: { key: string; value: string }): void => { + context.token = value.value + }, + // eslint-disable-next-line @typescript-eslint/no-empty-function + forEach: (): void => {}, + }, + clientTimezoneOffset: 0, +} + +export const cleanDB = async () => { + // this only works as long we do not have foreign key constraints + for (const entity of entities) { + await resetEntity(entity) + } +} + +const resetEntity = async (entity: any) => { + const items = await entity.find({ withDeleted: true }) + if (items.length > 0) { + const ids = items.map((e: any) => e.id) + await entity.delete(ids) + } +} + +const run = async () => { + const server = await createServer(context) + const seedClient = createTestClient(server.apollo) + const { con } = server + + // test GMS-Api Client + try { + const gmsComArray = await communityList() + logger.debug('GMS-Community-List:', gmsComArray) + const gmsUserArray = await userList() + logger.debug('GMS-Community-User-List:', gmsUserArray) + } catch (err) { + logger.error('Error in GMS-API:', err) + } + await con.close() +} + +void run() From 7296fae50327a66b92ed239aaa377b15bb1f09bc Mon Sep 17 00:00:00 2001 From: Claus-Peter Huebner Date: Tue, 28 Nov 2023 23:52:33 +0100 Subject: [PATCH 04/17] correct response processing after gms-request create community-user --- backend/src/apis/gms/GmsClient.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/apis/gms/GmsClient.ts b/backend/src/apis/gms/GmsClient.ts index ec3298267..6f92f3ee3 100644 --- a/backend/src/apis/gms/GmsClient.ts +++ b/backend/src/apis/gms/GmsClient.ts @@ -134,10 +134,10 @@ export async function createGmsUser(apiKey: string, user: GmsUser): Promise Date: Fri, 1 Dec 2023 00:36:25 +0100 Subject: [PATCH 05/17] add gms publishing in user creation --- backend/.env.dist | 2 + backend/.env.template | 1 + backend/src/apis/gms/GmsClient.ts | 30 ++++++------- backend/src/apis/gms/model/GmsEnums.ts | 12 +++++ backend/src/apis/gms/model/GmsUser.ts | 44 ++++++++++++------- backend/src/config/index.ts | 1 + backend/src/graphql/resolver/UserResolver.ts | 13 ++++++ .../graphql/resolver/util/sendUserToGms.ts | 27 ++++++++++++ backend/src/seeds/gmsUserList.ts | 13 ++---- 9 files changed, 102 insertions(+), 41 deletions(-) create mode 100644 backend/src/graphql/resolver/util/sendUserToGms.ts diff --git a/backend/.env.dist b/backend/.env.dist index 580f7ad2b..0164abff0 100644 --- a/backend/.env.dist +++ b/backend/.env.dist @@ -65,5 +65,7 @@ WEBHOOK_ELOPAGE_SECRET=secret FEDERATION_VALIDATE_COMMUNITY_TIMER=60000 # GMS +# GMS_ACTIVE=true +# Coordinates of Illuminz test instance GMS_HOST=54.176.169.179 GMS_PORT=3071 diff --git a/backend/.env.template b/backend/.env.template index 05cec536e..290d180b3 100644 --- a/backend/.env.template +++ b/backend/.env.template @@ -63,5 +63,6 @@ WEBHOOK_ELOPAGE_SECRET=$WEBHOOK_ELOPAGE_SECRET FEDERATION_VALIDATE_COMMUNITY_TIMER=$FEDERATION_VALIDATE_COMMUNITY_TIMER # GMS +GMS_ACTIVE=$GMS_ACTIVE GMS_HOST=$GMS_HOST GMS_PORT=$GMS_PORT diff --git a/backend/src/apis/gms/GmsClient.ts b/backend/src/apis/gms/GmsClient.ts index 6f92f3ee3..e4bdd4371 100644 --- a/backend/src/apis/gms/GmsClient.ts +++ b/backend/src/apis/gms/GmsClient.ts @@ -8,11 +8,11 @@ import { CONFIG } from '@/config' import { LogError } from '@/server/LogError' import { backendLogger as logger } from '@/server/logger' -import { GmsCommunity } from './model/GmsCommunity' import { GmsUser } from './model/GmsUser' +/* export async function communityList(): Promise { - const baseUrl = 'http://'.concat(CONFIG.GMS_HOST).concat(':').concat(CONFIG.GMS_PORT).concat('/') + const baseUrl = 'https://'.concat(CONFIG.GMS_HOST).concat(':').concat(CONFIG.GMS_PORT).concat('/') const service = 'community/list?page=1&perPage=20' const config = { headers: { @@ -32,10 +32,10 @@ export async function communityList(): Promise { - const baseUrl = 'http://'.concat(CONFIG.GMS_HOST).concat(':').concat(CONFIG.GMS_PORT).concat('/') + const baseUrl = 'https://'.concat(CONFIG.GMS_HOST).concat(':').concat(CONFIG.GMS_PORT).concat('/') const service = 'community-user/list?page=1&perPage=20' const config = { headers: { @@ -68,10 +68,10 @@ export async function userList(): Promise { } logger.debug('responseData:', result.data.responseData.data) // eslint-disable-next-line @typescript-eslint/no-unsafe-call - const gmsUser = JSON.parse(result.data.responseData.data) - logger.debug('gmsUser:', gmsUser) + // const gmsUser = JSON.parse(result.data.responseData.data) + // logger.debug('gmsUser:', gmsUser) // eslint-disable-next-line @typescript-eslint/no-unsafe-return - return gmsUser + return result.data.responseData.data } catch (error: any) { logger.error('Error in Get community-user/list:', error) const errMsg: string = error.message @@ -80,7 +80,7 @@ export async function userList(): Promise { } export async function userByUuid(uuid: string): Promise { - const baseUrl = 'http://'.concat(CONFIG.GMS_HOST).concat(':').concat(CONFIG.GMS_PORT).concat('/') + const baseUrl = 'https://'.concat(CONFIG.GMS_HOST).concat(':').concat(CONFIG.GMS_PORT).concat('/') const service = 'community-user/list?page=1&perPage=20' const config = { headers: { @@ -104,19 +104,20 @@ export async function userByUuid(uuid: string): Promise { - const baseUrl = 'http://'.concat(CONFIG.GMS_HOST).concat(':').concat(CONFIG.GMS_PORT).concat('/') + const baseUrl = 'https://'.concat(CONFIG.GMS_HOST).concat(':').concat(CONFIG.GMS_PORT).concat('/') const service = 'community-user' const config = { headers: { @@ -125,7 +126,6 @@ export async function createGmsUser(apiKey: string, user: GmsUser): Promise a.trim()) + .filter(Boolean) + .join(', ') + return address + } } } diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index d28256119..7efb1e91f 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -135,6 +135,7 @@ const federation = { } const gms = { + GMS_ACTIVE: process.env.GMS_ACTIVE === 'true' || false, // koordinates of Illuminz-instance of GMS GMS_HOST: process.env.GMS_HOST ?? 'localhost', GMS_PORT: process.env.GMS_PORT ?? '4044', diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 1f21abbb9..902abaf99 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -71,6 +71,7 @@ import { findUserByIdentifier } from './util/findUserByIdentifier' import { findUsers } from './util/findUsers' import { getKlicktippState } from './util/getKlicktippState' import { setUserRole, deleteUserRole } from './util/modifyUserRole' +import { sendUserToGms } from './util/sendUserToGms' import { validateAlias } from './util/validateAlias' const LANGUAGES = ['de', 'en', 'es', 'fr', 'nl'] @@ -361,6 +362,18 @@ export class UserResolver { } else { await EVENT_USER_REGISTER(dbUser) } + + if (CONFIG.GMS_ACTIVE) { + logger.info('GMS deactivated per configuration! New user is not published to GMS.') + } else { + try { + if (dbUser.gmsAllowed && !dbUser.gmsRegistered) { + await sendUserToGms(dbUser, homeCom) + } + } catch (err) { + logger.error('Error publishing new created user to GMS:', err) + } + } return new User(dbUser) } diff --git a/backend/src/graphql/resolver/util/sendUserToGms.ts b/backend/src/graphql/resolver/util/sendUserToGms.ts new file mode 100644 index 000000000..335141ffe --- /dev/null +++ b/backend/src/graphql/resolver/util/sendUserToGms.ts @@ -0,0 +1,27 @@ +import { Community as DbCommunity } from '@entity/Community' +import { User as DbUser } from '@entity/User' + +import { createGmsUser } from '@/apis/gms/GmsClient' +import { GmsUser } from '@/apis/gms/model/GmsUser' +import { LogError } from '@/server/LogError' +import { backendLogger as logger } from '@/server/logger' + +export async function sendUserToGms(user: DbUser, homeCom: DbCommunity): Promise { + if (homeCom.gmsApiKey === null) { + throw new LogError('HomeCommunity needs GMS-ApiKey to publish user data to GMS.') + } + logger.debug('User send to GMS:', user) + const gmsUser = new GmsUser(user) + try { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + if (await createGmsUser(homeCom.gmsApiKey, gmsUser)) { + logger.debug('GMS user published successfully:', gmsUser) + user.gmsRegistered = true + user.gmsRegisteredAt = new Date() + await DbUser.save(user) + logger.debug('mark user as gms published:', user) + } + } catch (err) { + logger.warn('publishing user fails with ', err) + } +} diff --git a/backend/src/seeds/gmsUserList.ts b/backend/src/seeds/gmsUserList.ts index 009c097a7..68bb86650 100644 --- a/backend/src/seeds/gmsUserList.ts +++ b/backend/src/seeds/gmsUserList.ts @@ -5,15 +5,10 @@ /* eslint-disable @typescript-eslint/no-unsafe-return */ import { entities } from '@entity/index' -import { User as DbUser } from '@entity/User' import { createTestClient } from 'apollo-server-testing' -import { communityList, createGmsUser, userList } from '@/apis/gms/GmsClient' -import { GmsUser } from '@/apis/gms/model/GmsUser' import { CONFIG } from '@/config' -import { getHomeCommunity } from '@/graphql/resolver/util/communities' import { createServer } from '@/server/createServer' -import { LogError } from '@/server/LogError' import { backendLogger as logger } from '@/server/logger' CONFIG.EMAIL = false @@ -52,10 +47,10 @@ const run = async () => { // test GMS-Api Client try { - const gmsComArray = await communityList() - logger.debug('GMS-Community-List:', gmsComArray) - const gmsUserArray = await userList() - logger.debug('GMS-Community-User-List:', gmsUserArray) + // const gmsComArray = await communityList() + // logger.debug('GMS-Community-List:', gmsComArray) + // const gmsUserArray = await userList() + // logger.debug('GMS-Community-User-List:', gmsUserArray) } catch (err) { logger.error('Error in GMS-API:', err) } From dec76f21676a18887b6c6ff8daee3e12a143943a Mon Sep 17 00:00:00 2001 From: Claus-Peter Huebner Date: Fri, 1 Dec 2023 01:06:26 +0100 Subject: [PATCH 06/17] linting --- backend/src/seeds/gmsUserList.ts | 4 ++-- backend/src/seeds/gmsUsers.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/seeds/gmsUserList.ts b/backend/src/seeds/gmsUserList.ts index 68bb86650..7603ca116 100644 --- a/backend/src/seeds/gmsUserList.ts +++ b/backend/src/seeds/gmsUserList.ts @@ -5,7 +5,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-return */ import { entities } from '@entity/index' -import { createTestClient } from 'apollo-server-testing' +// import { createTestClient } from 'apollo-server-testing' import { CONFIG } from '@/config' import { createServer } from '@/server/createServer' @@ -42,7 +42,7 @@ const resetEntity = async (entity: any) => { const run = async () => { const server = await createServer(context) - const seedClient = createTestClient(server.apollo) + // const seedClient = createTestClient(server.apollo) const { con } = server // test GMS-Api Client diff --git a/backend/src/seeds/gmsUsers.ts b/backend/src/seeds/gmsUsers.ts index c979ed29a..50cd67c52 100644 --- a/backend/src/seeds/gmsUsers.ts +++ b/backend/src/seeds/gmsUsers.ts @@ -6,7 +6,7 @@ import { entities } from '@entity/index' import { User as DbUser } from '@entity/User' -import { createTestClient } from 'apollo-server-testing' +// import { createTestClient } from 'apollo-server-testing' import { createGmsUser } from '@/apis/gms/GmsClient' import { GmsUser } from '@/apis/gms/model/GmsUser' @@ -47,7 +47,7 @@ const resetEntity = async (entity: any) => { const run = async () => { const server = await createServer(context) - const seedClient = createTestClient(server.apollo) + // const seedClient = createTestClient(server.apollo) const { con } = server const homeCom = await getHomeCommunity() From 9443a7d1b833957ba00a1927d55641b40fd8c805 Mon Sep 17 00:00:00 2001 From: Claus-Peter Huebner Date: Fri, 1 Dec 2023 01:28:47 +0100 Subject: [PATCH 07/17] adapt tests for gms user publishing --- backend/src/graphql/resolver/UserResolver.test.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index e16e0f0fc..2bcf3f165 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -177,6 +177,10 @@ describe('UserResolver', () => { passwordEncryptionType: PasswordEncryptionType.NO_PASSWORD, communityUuid: homeCom.communityUuid, foreign: false, + gmsAllowed: true, + gmsPublishName: 3, + gmsRegistered: false, + gmsRegisteredAt: null, }, ]) const valUUID = validateUUID(user[0].gradidoID) @@ -199,6 +203,14 @@ describe('UserResolver', () => { createdAt: expect.any(Date), deletedAt: null, updatedAt: null, + gmsPublishEmail: false, + gmsPublishPhone: 0, + gmsPublishPost: 0, + address: null, + city: null, + country: null, + countryCode: null, + zipCode: null, }) }) }) From a96aa9eb2b3cc27cf0cc2ebf344b4b01108fe47e Mon Sep 17 00:00:00 2001 From: Claus-Peter Huebner Date: Wed, 6 Dec 2023 21:29:18 +0100 Subject: [PATCH 08/17] use http for gms-requests --- backend/src/apis/gms/GmsClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/apis/gms/GmsClient.ts b/backend/src/apis/gms/GmsClient.ts index e4bdd4371..2767324e5 100644 --- a/backend/src/apis/gms/GmsClient.ts +++ b/backend/src/apis/gms/GmsClient.ts @@ -117,7 +117,7 @@ export async function userByUuid(uuid: string): Promise { - const baseUrl = 'https://'.concat(CONFIG.GMS_HOST).concat(':').concat(CONFIG.GMS_PORT).concat('/') + const baseUrl = 'http://'.concat(CONFIG.GMS_HOST).concat(':').concat(CONFIG.GMS_PORT).concat('/') const service = 'community-user' const config = { headers: { From a941d06b5579c93c85e7f25f4eff7ed92bca1ef5 Mon Sep 17 00:00:00 2001 From: Claus-Peter Huebner Date: Mon, 18 Dec 2023 18:17:46 +0100 Subject: [PATCH 09/17] configure gms-url instead of host and port --- backend/src/apis/gms/GmsClient.ts | 8 ++++---- backend/src/config/index.ts | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/backend/src/apis/gms/GmsClient.ts b/backend/src/apis/gms/GmsClient.ts index 2767324e5..46fa64006 100644 --- a/backend/src/apis/gms/GmsClient.ts +++ b/backend/src/apis/gms/GmsClient.ts @@ -12,7 +12,7 @@ import { GmsUser } from './model/GmsUser' /* export async function communityList(): Promise { - const baseUrl = 'https://'.concat(CONFIG.GMS_HOST).concat(':').concat(CONFIG.GMS_PORT).concat('/') + const baseUrl = CONFIG.GMS_URL.endsWith('/') ? CONFIG.GMS_URL : CONFIG.GMS_URL.concat('/') const service = 'community/list?page=1&perPage=20' const config = { headers: { @@ -44,7 +44,7 @@ export async function communityList(): Promise { - const baseUrl = 'https://'.concat(CONFIG.GMS_HOST).concat(':').concat(CONFIG.GMS_PORT).concat('/') + const baseUrl = CONFIG.GMS_URL.endsWith('/') ? CONFIG.GMS_URL : CONFIG.GMS_URL.concat('/') const service = 'community-user/list?page=1&perPage=20' const config = { headers: { @@ -80,7 +80,7 @@ export async function userList(): Promise { } export async function userByUuid(uuid: string): Promise { - const baseUrl = 'https://'.concat(CONFIG.GMS_HOST).concat(':').concat(CONFIG.GMS_PORT).concat('/') + const baseUrl = CONFIG.GMS_URL.endsWith('/') ? CONFIG.GMS_URL : CONFIG.GMS_URL.concat('/') const service = 'community-user/list?page=1&perPage=20' const config = { headers: { @@ -117,7 +117,7 @@ export async function userByUuid(uuid: string): Promise { - const baseUrl = 'http://'.concat(CONFIG.GMS_HOST).concat(':').concat(CONFIG.GMS_PORT).concat('/') + const baseUrl = CONFIG.GMS_URL.endsWith('/') ? CONFIG.GMS_URL : CONFIG.GMS_URL.concat('/') const service = 'community-user' const config = { headers: { diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 98698a731..1c88fcd8e 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -137,8 +137,7 @@ const federation = { const gms = { GMS_ACTIVE: process.env.GMS_ACTIVE === 'true' || false, // koordinates of Illuminz-instance of GMS - GMS_HOST: process.env.GMS_HOST ?? 'localhost', - GMS_PORT: process.env.GMS_PORT ?? '4044', + GMS_URL: process.env.GMS_HOST ?? 'http://localhost:4044/', } export const CONFIG = { From e699108952e6ed3d7c7bf53d632ae7a5e7e3d54a Mon Sep 17 00:00:00 2001 From: Claus-Peter Huebner Date: Mon, 18 Dec 2023 21:10:34 +0100 Subject: [PATCH 10/17] adapt database and entities on model of concept --- backend/src/apis/gms/model/GmsEnums.ts | 12 ---- backend/src/apis/gms/model/GmsUser.ts | 58 +------------------ .../src/graphql/resolver/UserResolver.test.ts | 11 ++-- backend/src/util/communityUser.ts | 2 + .../0079-introduce_gms_registration/User.ts | 13 +++++ .../UserContact.ts | 31 +++------- .../0079-introduce_gms_registration.ts | 32 ++++------ 7 files changed, 38 insertions(+), 121 deletions(-) diff --git a/backend/src/apis/gms/model/GmsEnums.ts b/backend/src/apis/gms/model/GmsEnums.ts index db6e82825..5fa08a3f7 100644 --- a/backend/src/apis/gms/model/GmsEnums.ts +++ b/backend/src/apis/gms/model/GmsEnums.ts @@ -24,18 +24,6 @@ registerEnumType(GmsPublishPhoneType, { description: 'Type of Phone publishing', // this one is optional }) -export enum GmsPublishPostType { - GMS_PUBLISH_POST_NOTHING = 0, - GMS_PUBLISH_POST_COUNTRY = 1, - GMS_PUBLISH_POST_CITY = 2, - GMS_PUBLISH_POST_FULL = 3, -} - -registerEnumType(GmsPublishPostType, { - name: 'GmsPublishPostType', // this one is mandatory - description: 'Type of name publishing', // this one is optional -}) - export enum GmsLocationType { GMS_LOCATION_TYPE_EXACT = 0, GMS_LOCATION_TYPE_APPROXIMATE = 1, diff --git a/backend/src/apis/gms/model/GmsUser.ts b/backend/src/apis/gms/model/GmsUser.ts index 0c0202b0f..efea12304 100644 --- a/backend/src/apis/gms/model/GmsUser.ts +++ b/backend/src/apis/gms/model/GmsUser.ts @@ -1,11 +1,6 @@ import { User as dbUser } from '@entity/User' -import { - GmsLocationType, - GmsPublishNameType, - GmsPublishPhoneType, - GmsPublishPostType, -} from './GmsEnums' +import { GmsLocationType, GmsPublishNameType, GmsPublishPhoneType } from './GmsEnums' export class GmsUser { constructor(user: dbUser) { @@ -17,10 +12,6 @@ export class GmsUser { this.firstName = this.getGmsFirstName(user) this.lastName = this.getGmsLastName(user) this.alias = user.alias ? user.alias : undefined - this.address = this.getGmsAddress(user) - // this.zipCode = this.getGmsZipCode(user) - // this.city = this.getGmsCity(user) - // this.country = this.getGmsCountry(user) this.type = GmsLocationType.GMS_LOCATION_TYPE_RANDOM this.location = null } @@ -97,51 +88,4 @@ export class GmsUser { return user.emailContact.phone } } - - private getGmsAddress(user: dbUser): string | undefined { - if (user.gmsAllowed) { - if (user.emailContact.gmsPublishPost === GmsPublishPostType.GMS_PUBLISH_POST_FULL) { - const address = [ - '' + user.emailContact.country, - ...(user.emailContact.zipCode ? user.emailContact.zipCode : ' '), - user.emailContact.city ? user.emailContact.city : ' ', - user.emailContact.address ? user.emailContact.address : ' ', - ] - .map((a) => a.trim()) - .filter(Boolean) - .join(', ') - return address - } - } - } - - private getGmsZipCode(user: dbUser): string | undefined { - if ( - user.gmsAllowed && - (user.emailContact.gmsPublishPost === GmsPublishPostType.GMS_PUBLISH_POST_CITY || - user.emailContact.gmsPublishPost === GmsPublishPostType.GMS_PUBLISH_POST_FULL) - ) { - return user.emailContact.zipCode - } - } - - private getGmsCity(user: dbUser): string | undefined { - if ( - user.gmsAllowed && - (user.emailContact.gmsPublishPost === GmsPublishPostType.GMS_PUBLISH_POST_CITY || - user.emailContact.gmsPublishPost === GmsPublishPostType.GMS_PUBLISH_POST_FULL) - ) { - return user.emailContact.city - } - } - - private getGmsCountry(user: dbUser): string | undefined { - if ( - user.gmsAllowed && - (user.emailContact.gmsPublishPost === GmsPublishPostType.GMS_PUBLISH_POST_COUNTRY || - user.emailContact.gmsPublishPost === GmsPublishPostType.GMS_PUBLISH_POST_FULL) - ) { - return user.emailContact.country - } - } } diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index 2bcf3f165..a4892496b 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -178,7 +178,9 @@ describe('UserResolver', () => { communityUuid: homeCom.communityUuid, foreign: false, gmsAllowed: true, - gmsPublishName: 3, + gmsPublishName: 0, + gmsPublishLocation: 2, + location: null, gmsRegistered: false, gmsRegisteredAt: null, }, @@ -199,18 +201,13 @@ describe('UserResolver', () => { emailVerificationCode: expect.any(String), emailOptInTypeId: OptInType.EMAIL_OPT_IN_REGISTER, emailResendCount: 0, + countryCode: null, phone: null, createdAt: expect.any(Date), deletedAt: null, updatedAt: null, gmsPublishEmail: false, gmsPublishPhone: 0, - gmsPublishPost: 0, - address: null, - city: null, - country: null, - countryCode: null, - zipCode: null, }) }) }) diff --git a/backend/src/util/communityUser.ts b/backend/src/util/communityUser.ts index a0c4bf681..9e337dfe7 100644 --- a/backend/src/util/communityUser.ts +++ b/backend/src/util/communityUser.ts @@ -52,6 +52,8 @@ const communityDbUser: dbUser = { communityUuid: '55555555-4444-4333-2222-11111111', gmsPublishName: 0, gmsAllowed: false, + location: null, + gmsPublishLocation: 2, gmsRegistered: false, gmsRegisteredAt: null, } diff --git a/database/entity/0079-introduce_gms_registration/User.ts b/database/entity/0079-introduce_gms_registration/User.ts index edcdd1257..f91129f31 100644 --- a/database/entity/0079-introduce_gms_registration/User.ts +++ b/database/entity/0079-introduce_gms_registration/User.ts @@ -7,6 +7,7 @@ import { OneToMany, JoinColumn, OneToOne, + Geometry, } from 'typeorm' import { Contribution } from '../Contribution' import { ContributionMessage } from '../ContributionMessage' @@ -124,6 +125,18 @@ export class User extends BaseEntity { @Column({ name: 'gms_allowed', type: 'bool', default: true }) gmsAllowed: boolean + @Column({ name: 'location', type: 'geometry', default: null, nullable: true }) + location: Geometry | null + + @Column({ + name: 'gms_publish_location', + type: 'int', + unsigned: true, + nullable: false, + default: 2, + }) + gmsPublishLocation: number + @Column({ name: 'gms_registered', type: 'bool', default: false }) gmsRegistered: boolean diff --git a/database/entity/0079-introduce_gms_registration/UserContact.ts b/database/entity/0079-introduce_gms_registration/UserContact.ts index a3d0a8f52..82ae4c013 100644 --- a/database/entity/0079-introduce_gms_registration/UserContact.ts +++ b/database/entity/0079-introduce_gms_registration/UserContact.ts @@ -5,6 +5,8 @@ import { Column, DeleteDateColumn, OneToOne, + CreateDateColumn, + UpdateDateColumn, } from 'typeorm' import { User } from '../User' @@ -61,31 +63,14 @@ export class UserContact extends BaseEntity { @Column({ name: 'gms_publish_phone', type: 'int', unsigned: true, nullable: false, default: 0 }) gmsPublishPhone: number - @Column({ length: 255, unique: false, nullable: true, collation: 'utf8mb4_unicode_ci' }) - address: string - - @Column({ length: 255, unique: false, nullable: true, collation: 'utf8mb4_unicode_ci' }) - city: string - - @Column({ - name: 'zip_code', - length: 255, - unique: false, - nullable: true, - collation: 'utf8mb4_unicode_ci', - }) - zipCode: string - - @Column({ length: 255, unique: false, nullable: true, collation: 'utf8mb4_unicode_ci' }) - country: string - - @Column({ name: 'gms_publish_post', type: 'int', unsigned: true, nullable: false, default: 0 }) - gmsPublishPost: number - - @Column({ name: 'created_at', default: () => 'CURRENT_TIMESTAMP', nullable: false }) + @CreateDateColumn({ name: 'created_at', default: () => 'CURRENT_TIMESTAMP(3)', nullable: false }) createdAt: Date - @Column({ name: 'updated_at', nullable: true, default: null, type: 'datetime' }) + @UpdateDateColumn({ + name: 'updated_at', + nullable: true, + onUpdate: 'CURRENT_TIMESTAMP(3)', + }) updatedAt: Date | null @DeleteDateColumn({ name: 'deleted_at', nullable: true }) diff --git a/database/migrations/0079-introduce_gms_registration.ts b/database/migrations/0079-introduce_gms_registration.ts index 6de55333f..e02801a4f 100644 --- a/database/migrations/0079-introduce_gms_registration.ts +++ b/database/migrations/0079-introduce_gms_registration.ts @@ -6,11 +6,17 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis 'ALTER TABLE `users` MODIFY COLUMN `foreign` tinyint(1) NOT NULL DEFAULT 0 AFTER `id`;', ) await queryFn( - 'ALTER TABLE `users` ADD COLUMN IF NOT EXISTS `gms_publish_name` int unsigned NOT NULL DEFAULT 3 AFTER `last_name`;', // COMMENT '0:nothing, 1:initials only, 2:firstName only, 3:firstName + Initial of LastName, 4:fullName' + 'ALTER TABLE `users` ADD COLUMN IF NOT EXISTS `gms_publish_name` int unsigned NOT NULL DEFAULT 0 AFTER `last_name`;', // COMMENT '0:alias if exists or initials only , 1:initials only, 2:firstName only, 3:firstName + Initial of LastName, 4:fullName' ) await queryFn( 'ALTER TABLE `users` ADD COLUMN IF NOT EXISTS `gms_allowed` tinyint(1) NOT NULL DEFAULT 1;', ) + await queryFn( + 'ALTER TABLE `users` ADD COLUMN IF NOT EXISTS `location` geometry DEFAULT NULL NULL AFTER `gms_allowed`;', + ) + await queryFn( + 'ALTER TABLE `users` ADD COLUMN IF NOT EXISTS `gms_publish_location` int unsigned NOT NULL DEFAULT 2 AFTER `location`;', // COMMENT '0:exact, 1:approximate, 2:random' + ) await queryFn( 'ALTER TABLE `users` ADD COLUMN IF NOT EXISTS `gms_registered` tinyint(1) NOT NULL DEFAULT 0;', ) @@ -26,21 +32,6 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis await queryFn( 'ALTER TABLE `user_contacts` ADD COLUMN IF NOT EXISTS `gms_publish_phone` int unsigned NOT NULL DEFAULT 0 AFTER `phone`;', // COMMENT '0:nothing, 1:country_code only, 2:complet phone number' ) - await queryFn( - 'ALTER TABLE `user_contacts` ADD COLUMN IF NOT EXISTS `address` varchar(255) DEFAULT NULL NULL AFTER `gms_publish_phone`;', - ) - await queryFn( - 'ALTER TABLE `user_contacts` ADD COLUMN IF NOT EXISTS `city` varchar(255) DEFAULT NULL NULL AFTER `address`;', - ) - await queryFn( - 'ALTER TABLE `user_contacts` ADD COLUMN IF NOT EXISTS `zip_code` varchar(255) DEFAULT NULL NULL AFTER `city`;', - ) - await queryFn( - 'ALTER TABLE `user_contacts` ADD COLUMN IF NOT EXISTS `country` varchar(255) DEFAULT NULL NULL AFTER `zip_code`;', - ) - await queryFn( - 'ALTER TABLE `user_contacts` ADD COLUMN IF NOT EXISTS `gms_publish_post` int unsigned NOT NULL DEFAULT 0 AFTER `country`;', // COMMENT '0:nothing, 1:country, 2:city, 3: detailed address' - ) await queryFn( 'ALTER TABLE `communities` ADD COLUMN IF NOT EXISTS `gms_api_key` varchar(512) DEFAULT NULL NULL AFTER `description`;', ) @@ -52,15 +43,12 @@ export async function downgrade(queryFn: (query: string, values?: any[]) => Prom ) await queryFn('ALTER TABLE `users` DROP COLUMN IF EXISTS `gms_publish_name`;') await queryFn('ALTER TABLE `users` DROP COLUMN IF EXISTS `gms_allowed`;') + await queryFn('ALTER TABLE `users` DROP COLUMN IF EXISTS `location`;') + await queryFn('ALTER TABLE `users` DROP COLUMN IF EXISTS `gms_publish_location`;') await queryFn('ALTER TABLE `users` DROP COLUMN IF EXISTS `gms_registered`;') await queryFn('ALTER TABLE `users` DROP COLUMN IF EXISTS `gms_registered_at`;') await queryFn('ALTER TABLE `user_contacts` DROP COLUMN IF EXISTS `gms_publish_email`;') await queryFn('ALTER TABLE `user_contacts` DROP COLUMN IF EXISTS `country_code`;') await queryFn('ALTER TABLE `user_contacts` DROP COLUMN IF EXISTS `gms_publish_phone`;') - await queryFn('ALTER TABLE `user_contacts` DROP COLUMN IF EXISTS `address`;') - await queryFn('ALTER TABLE `user_contacts` DROP COLUMN IF EXISTS `city`;') - await queryFn('ALTER TABLE `user_contacts` DROP COLUMN IF EXISTS `zip_code`;') - await queryFn('ALTER TABLE `user_contacts` DROP COLUMN IF EXISTS `country`;') - await queryFn('ALTER TABLE `user_contacts` DROP COLUMN IF EXISTS `gms_publish_post`;') - await queryFn('ALTER TABLE `communities` DROP COLUMN IF EXISTS `gms_api_key`;') + await queryFn('ALTER TABLE `communities` DROP COLUMN IF EXISTS `gms_api_key`;') } From ef73207609732abb605a5c9c32864c1dee53a60b Mon Sep 17 00:00:00 2001 From: Claus-Peter Huebner Date: Wed, 20 Dec 2023 21:07:15 +0100 Subject: [PATCH 11/17] adapt user migrations on concept requirements --- backend/src/apis/gms/model/GmsEnums.ts | 2 +- backend/src/apis/gms/model/GmsUser.ts | 27 ++++++++++++++---- backend/src/seeds/gmsUsers.ts | 38 ++++++++++++++++---------- 3 files changed, 47 insertions(+), 20 deletions(-) diff --git a/backend/src/apis/gms/model/GmsEnums.ts b/backend/src/apis/gms/model/GmsEnums.ts index 5fa08a3f7..1342327d1 100644 --- a/backend/src/apis/gms/model/GmsEnums.ts +++ b/backend/src/apis/gms/model/GmsEnums.ts @@ -1,7 +1,7 @@ import { registerEnumType } from 'type-graphql' export enum GmsPublishNameType { - GMS_PUBLISH_NAME_NOTHING = 0, + GMS_PUBLISH_NAME_ALIAS_OR_INITALS = 0, GMS_PUBLISH_NAME_INITIALS = 1, GMS_PUBLISH_NAME_FIRST = 2, GMS_PUBLISH_NAME_FIRST_INITIAL = 3, diff --git a/backend/src/apis/gms/model/GmsUser.ts b/backend/src/apis/gms/model/GmsUser.ts index efea12304..2fad3bd1e 100644 --- a/backend/src/apis/gms/model/GmsUser.ts +++ b/backend/src/apis/gms/model/GmsUser.ts @@ -11,7 +11,7 @@ export class GmsUser { this.mobile = this.getGmsPhone(user) this.firstName = this.getGmsFirstName(user) this.lastName = this.getGmsLastName(user) - this.alias = user.alias ? user.alias : undefined + this.alias = this.getGmsAlias(user) this.type = GmsLocationType.GMS_LOCATION_TYPE_RANDOM this.location = null } @@ -37,6 +37,16 @@ export class GmsUser { language: string location: unknown + private getGmsAlias(user: dbUser): string | undefined { + if ( + user.gmsAllowed && + user.alias && + user.gmsPublishName === GmsPublishNameType.GMS_PUBLISH_NAME_ALIAS_OR_INITALS + ) { + return user.alias + } + } + private getGmsFirstName(user: dbUser): string | undefined { if ( user.gmsAllowed && @@ -46,8 +56,13 @@ export class GmsUser { ) { return user.firstName } - if (user.gmsAllowed && user.gmsPublishName === GmsPublishNameType.GMS_PUBLISH_NAME_INITIALS) { - return user.firstName.substring(0, 1) + '.' + if ( + user.gmsAllowed && + ((!user.alias && + user.gmsPublishName === GmsPublishNameType.GMS_PUBLISH_NAME_ALIAS_OR_INITALS) || + user.gmsPublishName === GmsPublishNameType.GMS_PUBLISH_NAME_INITIALS) + ) { + return user.firstName.substring(0, 1) } } @@ -57,10 +72,12 @@ export class GmsUser { } if ( user.gmsAllowed && - (user.gmsPublishName === GmsPublishNameType.GMS_PUBLISH_NAME_FIRST_INITIAL || + ((!user.alias && + user.gmsPublishName === GmsPublishNameType.GMS_PUBLISH_NAME_ALIAS_OR_INITALS) || + user.gmsPublishName === GmsPublishNameType.GMS_PUBLISH_NAME_FIRST_INITIAL || user.gmsPublishName === GmsPublishNameType.GMS_PUBLISH_NAME_INITIALS) ) { - return user.lastName.substring(0, 1) + '.' + return user.lastName.substring(0, 1) } } diff --git a/backend/src/seeds/gmsUsers.ts b/backend/src/seeds/gmsUsers.ts index 50cd67c52..6f636bd8c 100644 --- a/backend/src/seeds/gmsUsers.ts +++ b/backend/src/seeds/gmsUsers.ts @@ -55,9 +55,15 @@ const run = async () => { throw new LogError('HomeCommunity needs GMS-ApiKey to publish user data to GMS.') } // read the ids of all local users, which are still not gms registered - const userIds = await DbUser.query( - 'SELECT `id` from `users` `u` where `u`.`foreign` = false and `deleted_at` is null and `gms_registered` = false', - ) + const userIds = await DbUser.createQueryBuilder() + .select('id') + .where({ foreign: false }) + .andWhere('deleted_at is null') + .andWhere({ gmsRegistered: false }) + .getRawMany() + // const userIds = await DbUser.query( + // 'SELECT `id` from `users` `u` where `u`.`foreign` = false and `deleted_at` is null and `gms_registered` = false', + // ) logger.debug('userIds:', userIds) for (const idStr of userIds) { @@ -68,18 +74,22 @@ const run = async () => { }) if (user) { logger.debug('found local User:', user) - const gmsUser = new GmsUser(user) - try { - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument - if (await createGmsUser(homeCom.gmsApiKey, gmsUser)) { - logger.debug('GMS user published successfully:', gmsUser) - user.gmsRegistered = true - user.gmsRegisteredAt = new Date() - await DbUser.save(user) - logger.debug('mark user as gms published:', user) + if (user.gmsAllowed) { + const gmsUser = new GmsUser(user) + try { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + if (await createGmsUser(homeCom.gmsApiKey, gmsUser)) { + logger.debug('GMS user published successfully:', gmsUser) + user.gmsRegistered = true + user.gmsRegisteredAt = new Date() + await DbUser.save(user) + logger.debug('mark user as gms published:', user) + } + } catch (err) { + logger.warn('publishing user fails with ', err) } - } catch (err) { - logger.warn('publishing user fails with ', err) + } else { + logger.debug('GMS-Publishing not allowed by user settings:', user) } } } From a281313a38a5818002d4a7cf503841832d890993 Mon Sep 17 00:00:00 2001 From: Claus-Peter Huebner Date: Wed, 20 Dec 2023 21:24:07 +0100 Subject: [PATCH 12/17] correct logic for check active gms config on createUser --- backend/src/graphql/resolver/UserResolver.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 902abaf99..45053bda4 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -363,7 +363,7 @@ export class UserResolver { await EVENT_USER_REGISTER(dbUser) } - if (CONFIG.GMS_ACTIVE) { + if (!CONFIG.GMS_ACTIVE) { logger.info('GMS deactivated per configuration! New user is not published to GMS.') } else { try { From 34ff70c9ba8408b9b14f3ed9934af10579c58e2c Mon Sep 17 00:00:00 2001 From: Claus-Peter Huebner Date: Wed, 20 Dec 2023 22:43:14 +0100 Subject: [PATCH 13/17] remove comment --- backend/src/seeds/gmsUsers.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/backend/src/seeds/gmsUsers.ts b/backend/src/seeds/gmsUsers.ts index 6f636bd8c..5a06ef6ea 100644 --- a/backend/src/seeds/gmsUsers.ts +++ b/backend/src/seeds/gmsUsers.ts @@ -61,9 +61,6 @@ const run = async () => { .andWhere('deleted_at is null') .andWhere({ gmsRegistered: false }) .getRawMany() - // const userIds = await DbUser.query( - // 'SELECT `id` from `users` `u` where `u`.`foreign` = false and `deleted_at` is null and `gms_registered` = false', - // ) logger.debug('userIds:', userIds) for (const idStr of userIds) { From 044aff20c388e0049054bbfe666e9feb2573d295 Mon Sep 17 00:00:00 2001 From: Claus-Peter Huebner Date: Wed, 20 Dec 2023 23:00:42 +0100 Subject: [PATCH 14/17] gms user-migration job uses same `sendUserToGms` as in createUser --- backend/src/seeds/gmsUsers.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/src/seeds/gmsUsers.ts b/backend/src/seeds/gmsUsers.ts index 5a06ef6ea..3a2dd3783 100644 --- a/backend/src/seeds/gmsUsers.ts +++ b/backend/src/seeds/gmsUsers.ts @@ -12,6 +12,7 @@ import { createGmsUser } from '@/apis/gms/GmsClient' import { GmsUser } from '@/apis/gms/model/GmsUser' import { CONFIG } from '@/config' import { getHomeCommunity } from '@/graphql/resolver/util/communities' +import { sendUserToGms } from '@/graphql/resolver/util/sendUserToGms' import { createServer } from '@/server/createServer' import { LogError } from '@/server/LogError' import { backendLogger as logger } from '@/server/logger' @@ -73,6 +74,8 @@ const run = async () => { logger.debug('found local User:', user) if (user.gmsAllowed) { const gmsUser = new GmsUser(user) + await sendUserToGms(user, homeCom) + /* try { // eslint-disable-next-line @typescript-eslint/no-unsafe-argument if (await createGmsUser(homeCom.gmsApiKey, gmsUser)) { @@ -85,6 +88,7 @@ const run = async () => { } catch (err) { logger.warn('publishing user fails with ', err) } + */ } else { logger.debug('GMS-Publishing not allowed by user settings:', user) } From 0cd61e43ac4ef7212f2ff8d0019b184b6b1ade82 Mon Sep 17 00:00:00 2001 From: Claus-Peter Huebner Date: Wed, 20 Dec 2023 23:08:04 +0100 Subject: [PATCH 15/17] add GMS config in .env.dist and .env.template --- backend/.env.dist | 4 ++-- backend/.env.template | 3 +-- deployment/bare_metal/.env.dist | 6 ++++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/backend/.env.dist b/backend/.env.dist index 0164abff0..fb95e984c 100644 --- a/backend/.env.dist +++ b/backend/.env.dist @@ -67,5 +67,5 @@ FEDERATION_VALIDATE_COMMUNITY_TIMER=60000 # GMS # GMS_ACTIVE=true # Coordinates of Illuminz test instance -GMS_HOST=54.176.169.179 -GMS_PORT=3071 +#GMS_URL=http://54.176.169.179:3071 +GMS_URL=http://localhost:4044/ diff --git a/backend/.env.template b/backend/.env.template index 290d180b3..97fd235ec 100644 --- a/backend/.env.template +++ b/backend/.env.template @@ -64,5 +64,4 @@ FEDERATION_VALIDATE_COMMUNITY_TIMER=$FEDERATION_VALIDATE_COMMUNITY_TIMER # GMS GMS_ACTIVE=$GMS_ACTIVE -GMS_HOST=$GMS_HOST -GMS_PORT=$GMS_PORT +GMS_URL=$GMS_URL diff --git a/deployment/bare_metal/.env.dist b/deployment/bare_metal/.env.dist index 1335e06a5..aa6c6cade 100644 --- a/deployment/bare_metal/.env.dist +++ b/deployment/bare_metal/.env.dist @@ -95,3 +95,9 @@ ADMIN_CONFIG_VERSION=v1.2022-03-18 WALLET_AUTH_URL=https://stage1.gradido.net/authenticate?token={token} WALLET_URL=https://stage1.gradido.net/login + +# GMS +#GMS_ACTIVE=true +# Coordinates of Illuminz test instance +#GMS_URL=http://54.176.169.179:3071 +#GMS_URL=http://localhost:4044/ From 656f1da9b2a508a22497a708bb587db1f3b77ac4 Mon Sep 17 00:00:00 2001 From: Claus-Peter Huebner Date: Wed, 20 Dec 2023 23:16:04 +0100 Subject: [PATCH 16/17] linting --- backend/src/seeds/gmsUsers.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/seeds/gmsUsers.ts b/backend/src/seeds/gmsUsers.ts index 3a2dd3783..46a8998e1 100644 --- a/backend/src/seeds/gmsUsers.ts +++ b/backend/src/seeds/gmsUsers.ts @@ -8,8 +8,8 @@ import { entities } from '@entity/index' import { User as DbUser } from '@entity/User' // import { createTestClient } from 'apollo-server-testing' -import { createGmsUser } from '@/apis/gms/GmsClient' -import { GmsUser } from '@/apis/gms/model/GmsUser' +// import { createGmsUser } from '@/apis/gms/GmsClient' +// import { GmsUser } from '@/apis/gms/model/GmsUser' import { CONFIG } from '@/config' import { getHomeCommunity } from '@/graphql/resolver/util/communities' import { sendUserToGms } from '@/graphql/resolver/util/sendUserToGms' @@ -73,9 +73,9 @@ const run = async () => { if (user) { logger.debug('found local User:', user) if (user.gmsAllowed) { - const gmsUser = new GmsUser(user) await sendUserToGms(user, homeCom) /* + const gmsUser = new GmsUser(user) try { // eslint-disable-next-line @typescript-eslint/no-unsafe-argument if (await createGmsUser(homeCom.gmsApiKey, gmsUser)) { From fed0e7e09cc6357a11c2132b5f8d19913ccebd3d Mon Sep 17 00:00:00 2001 From: clauspeterhuebner <86960882+clauspeterhuebner@users.noreply.github.com> Date: Fri, 9 Feb 2024 21:49:36 +0100 Subject: [PATCH 17/17] Update deployment/bare_metal/.env.dist Sorry, these lines were part of merge conflicts and not clear for me what to do... Co-authored-by: einhornimmond --- deployment/bare_metal/.env.dist | 2 -- 1 file changed, 2 deletions(-) diff --git a/deployment/bare_metal/.env.dist b/deployment/bare_metal/.env.dist index b6b158b87..f9b6b0a5d 100644 --- a/deployment/bare_metal/.env.dist +++ b/deployment/bare_metal/.env.dist @@ -120,8 +120,6 @@ NGINX_REWRITE_LEGACY_URLS=false DEFAULT_PUBLISHER_ID=2896 WEBHOOK_ELOPAGE_SECRET=secret -WALLET_AUTH_URL=https://stage1.gradido.net/authenticate?token={token} -WALLET_URL=https://stage1.gradido.net/login # GMS #GMS_ACTIVE=true