mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
Merge remote-tracking branch
'origin/2946-feature-x-com-3-introduce-business-communities' into 2956-feature-x-com-4-introduce-public-community-info-handshake
This commit is contained in:
commit
c3216c39ad
@ -2,10 +2,10 @@
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
import { FederatedCommunity as DbFederatedCommunity } from '@entity/FederatedCommunity'
|
||||
import { GraphQLError } from 'graphql/error/GraphQLError'
|
||||
import { gql } from 'graphql-request'
|
||||
|
||||
import { GraphQLGetClient } from '@/federation/client/GraphQLGetClient'
|
||||
import { LogError } from '@/server/LogError'
|
||||
import { backendLogger as logger } from '@/server/logger'
|
||||
|
||||
// eslint-disable-next-line import/no-relative-parent-imports
|
||||
@ -41,7 +41,10 @@ export class FederationClientImpl implements FederationClient {
|
||||
}
|
||||
logger.warn(`requestGetPublicKey processed without response data`)
|
||||
} catch (err) {
|
||||
throw new LogError(`Request-Error:`, err)
|
||||
if (err instanceof GraphQLError) {
|
||||
logger.error(`RawRequest-Error on {} with message {}`, endpoint, err.message)
|
||||
}
|
||||
throw new Error(`Request-Error in requestGetPublicKey.`)
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,7 +82,10 @@ export class FederationClientImpl implements FederationClient {
|
||||
}
|
||||
logger.warn(`requestGetPublicInfo processed without response data`)
|
||||
} catch (err) {
|
||||
throw new LogError(`Request-Error:`, err)
|
||||
if (err instanceof GraphQLError) {
|
||||
logger.error(`RawRequest-Error on {} with message {}`, endpoint, err.message)
|
||||
}
|
||||
throw new Error(`Request-Error in requestGetPublicCommunityInfo.`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,10 +2,10 @@
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
import { FederatedCommunity as DbFederatedCommunity } from '@entity/FederatedCommunity'
|
||||
import { GraphQLError } from 'graphql/error/GraphQLError'
|
||||
import { gql } from 'graphql-request'
|
||||
|
||||
import { GraphQLGetClient } from '@/federation/client/GraphQLGetClient'
|
||||
import { LogError } from '@/server/LogError'
|
||||
import { backendLogger as logger } from '@/server/logger'
|
||||
|
||||
// eslint-disable-next-line import/no-relative-parent-imports
|
||||
@ -41,7 +41,10 @@ export class FederationClientImpl implements FederationClient {
|
||||
}
|
||||
logger.warn(`requestGetPublicKey processed without response data`)
|
||||
} catch (err) {
|
||||
throw new LogError(`Request-Error:`, err)
|
||||
if (err instanceof GraphQLError) {
|
||||
logger.error(`RawRequest-Error on {} with message {}`, endpoint, err.message)
|
||||
}
|
||||
throw new Error(`Request-Error in requestGetPublicKey.`)
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,7 +85,10 @@ export class FederationClientImpl implements FederationClient {
|
||||
}
|
||||
logger.warn(`requestGetPublicInfo processed without response data`)
|
||||
} catch (err) {
|
||||
throw new LogError(`Request-Error:`, err)
|
||||
if (err instanceof GraphQLError) {
|
||||
logger.error(`RawRequest-Error on {} with message {}`, endpoint, err.message)
|
||||
}
|
||||
throw new Error(`Request-Error in requestGetPublicCommunityInfo.`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,6 @@ import { IsNull } from '@dbTools/typeorm'
|
||||
import { Community as DbCommunity } from '@entity/Community'
|
||||
import { FederatedCommunity as DbFederatedCommunity } from '@entity/FederatedCommunity'
|
||||
|
||||
import { LogError } from '@/server/LogError'
|
||||
import { backendLogger as logger } from '@/server/logger'
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
@ -76,9 +75,7 @@ export async function validateCommunities(): Promise<void> {
|
||||
// DbCommunity.delete({ id: dbCom.id })
|
||||
}
|
||||
} catch (err) {
|
||||
if (!isLogError(err)) {
|
||||
logger.error(`Error:`, err)
|
||||
}
|
||||
logger.error(`Error:`, err)
|
||||
}
|
||||
} else {
|
||||
logger.warn(
|
||||
@ -93,20 +90,24 @@ async function writeForeignCommunity(
|
||||
dbCom: DbFederatedCommunity,
|
||||
pubInfo: PublicCommunityInfo,
|
||||
): Promise<void> {
|
||||
if (dbCom && pubInfo) {
|
||||
const foreignCom = DbCommunity.create()
|
||||
foreignCom.foreign = true
|
||||
foreignCom.publicKey = dbCom.publicKey
|
||||
foreignCom.url = dbCom.endPoint
|
||||
foreignCom.name = pubInfo.name
|
||||
foreignCom.description = pubInfo.description
|
||||
foreignCom.creationDate = pubInfo.createdAt
|
||||
await DbCommunity.save(foreignCom)
|
||||
const variables = {
|
||||
public_key: pubInfo.publicKey,
|
||||
url: dbCom.endPoint,
|
||||
name: pubInfo.name,
|
||||
description: pubInfo.description,
|
||||
creation_date: pubInfo.createdAt,
|
||||
}
|
||||
if (dbCom && pubInfo) {
|
||||
await DbCommunity.createQueryBuilder()
|
||||
.insert()
|
||||
.into(DbCommunity)
|
||||
.values(variables)
|
||||
.orUpdate({
|
||||
conflict_target: ['id', 'public_key'],
|
||||
overwrite: ['url', 'name', 'description', 'creation_date'],
|
||||
})
|
||||
.execute()
|
||||
}
|
||||
}
|
||||
|
||||
function isLogError(err: unknown) {
|
||||
return err instanceof LogError
|
||||
}
|
||||
|
||||
function getVersionedFederationClient(apiVersion: string): FederationClient {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user