mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
gmsuserList as new yarn-script
This commit is contained in:
parent
fe5234806a
commit
55671eb81a
@ -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": {
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
@ -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<void> {
|
||||
logger.info(
|
||||
@ -30,16 +29,6 @@ export async function startValidateCommunities(timerInterval: number): Promise<v
|
||||
}
|
||||
|
||||
export async function validateCommunities(): Promise<void> {
|
||||
// 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() })
|
||||
|
||||
65
backend/src/seeds/gmsUserList.ts
Normal file
65
backend/src/seeds/gmsUserList.ts
Normal file
@ -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()
|
||||
Loading…
x
Reference in New Issue
Block a user