From 09f261c1ebfcaad8e0865b54df291d945fd5df84 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 27 Oct 2025 13:27:49 +0100 Subject: [PATCH] rollback change, because moved in other pr --- backend/src/federation/validateCommunities.ts | 51 ------------------- 1 file changed, 51 deletions(-) diff --git a/backend/src/federation/validateCommunities.ts b/backend/src/federation/validateCommunities.ts index 3b910b313..ac9334977 100644 --- a/backend/src/federation/validateCommunities.ts +++ b/backend/src/federation/validateCommunities.ts @@ -2,7 +2,6 @@ import { Community as DbCommunity, FederatedCommunity as DbFederatedCommunity, getHomeCommunity, - getReachableCommunities, } from 'database' import { IsNull } from 'typeorm' @@ -16,9 +15,6 @@ import { getLogger } from 'log4js' import { startCommunityAuthentication } from './authenticateCommunities' import { PublicCommunityInfoLoggingView } from './client/1_0/logging/PublicCommunityInfoLogging.view' import { ApiVersionType } from 'core' -import { CONFIG } from '@/config' -import * as path from 'node:path' -import * as fs from 'node:fs' const logger = getLogger(`${LOG4JS_BASE_CATEGORY_NAME}.federation.validateCommunities`) @@ -87,8 +83,6 @@ export async function validateCommunities(): Promise { logger.error(`Error:`, err) } } - // export communities for gradido dlt node server - await exportCommunitiesToDltNodeServer() } export async function writeJwtKeyPairInHomeCommunity(): Promise { @@ -148,48 +142,3 @@ async function writeForeignCommunity( await DbCommunity.save(com) } } - -// prototype, later add api call to gradido dlt node server for adding/updating communities -type CommunityForDltNodeServer = { - communityId: string - hieroTopicId: string - alias: string - folder: string -} -async function exportCommunitiesToDltNodeServer(): Promise { - if (!CONFIG.DLT_CONNECTOR) { - return Promise.resolve() - } - const folder = CONFIG.DLT_GRADIDO_NODE_SERVER_HOME_FOLDER - try { - fs.accessSync(folder, fs.constants.R_OK | fs.constants.W_OK) - } catch (err) { - logger.error(`Error: home folder for DLT Gradido Node Server ${folder} does not exist`) - return - } - - const dbComs = await getReachableCommunities(CONFIG.FEDERATION_VALIDATE_COMMUNITY_TIMER * 4) - const communitiesForDltNodeServer: CommunityForDltNodeServer[] = [] - // make sure communityName is unique - const communityName = new Set() - dbComs.forEach((com) => { - if (!com.communityUuid || !com.hieroTopicId) { - return - } - let alias = com.name - if (!alias || communityName.has(alias)) { - alias = com.communityUuid - } - communityName.add(alias) - communitiesForDltNodeServer.push({ - communityId: com.communityUuid, - hieroTopicId: com.hieroTopicId, - alias, - // use only alpha-numeric chars for folder name - folder: alias.replace(/[^a-zA-Z0-9]/g, '_') - }) - }) - const dltNodeServerCommunitiesFile = path.join(folder, 'communities.json') - fs.writeFileSync(dltNodeServerCommunitiesFile, JSON.stringify(communitiesForDltNodeServer, null, 2)) - logger.debug(`Written communitiesForDltNodeServer to ${dltNodeServerCommunitiesFile}`) -}