diff --git a/packages/basic.gblib/services/SystemKeywords.ts b/packages/basic.gblib/services/SystemKeywords.ts index a2d4fa7f..e2507257 100644 --- a/packages/basic.gblib/services/SystemKeywords.ts +++ b/packages/basic.gblib/services/SystemKeywords.ts @@ -73,6 +73,7 @@ import { Page } from 'facebook-nodejs-business-sdk'; import { md5 } from 'js-md5'; import { GBUtil } from '../../../src/util.js'; +import { Client } from 'minio'; /** * @fileoverview General Bots server core. @@ -1175,8 +1176,44 @@ export class SystemKeywords { } else if (file.indexOf('.csv') !== -1) { let res; let packagePath = GBUtil.getGBAIPath(min.botId, `gbdata`); + + if (GBConfigService.get('GB_MODE') === 'gbcluster') { + + const fileUrl = urlJoin('/', `${min.botId}.gbdata`, file); + GBLogEx.info(min, `Direct data from .csv: ${fileUrl}.`); + + const fileOnly = fileUrl.substring(fileUrl.lastIndexOf('/') + 1); + + const minioClient = new Client({ + endPoint: process.env.DRIVE_SERVER || 'localhost', + port: parseInt(process.env.DRIVE_PORT || '9000', 10), + useSSL: process.env.DRIVE_USE_SSL === 'true', + accessKey: process.env.DRIVE_ACCESSKEY, + secretKey: process.env.DRIVE_SECRET, + }); + + const bucketName = (process.env.DRIVE_ORG_PREFIX + min.botId + '.gbai').toLowerCase(); + const localName = path.join( + 'work', + gbaiName, + 'cache', + `${fileOnly.replace(/\s/gi, '')}-${GBAdminService.getNumberIdentifier()}.${ext}` + ); + + await minioClient.fGetObject(bucketName, fileUrl, localName); + } + else { + + } + + + const csvFile = path.join(GBConfigService.get('STORAGE_LIBRARY'), packagePath, file); const data = await fs.readFile(csvFile, 'utf8'); + + + + const firstLine = data.split('\n')[0]; const headers = firstLine.split(','); const db = await csvdb(csvFile, headers, ','); diff --git a/packages/core.gbapp/services/GBMinService.ts b/packages/core.gbapp/services/GBMinService.ts index a2268e75..c7b12e5a 100644 --- a/packages/core.gbapp/services/GBMinService.ts +++ b/packages/core.gbapp/services/GBMinService.ts @@ -465,8 +465,7 @@ export class GBMinService { .all(`/${min.instance.botId}/whatsapp`, async (req, res) => { const challenge = (min.core['getParam'] as any)(min.instance, `Meta Challenge`, null, true); - GBLogEx.info(min, `Meta callback entering...${challenge} ${JSON.stringify(req.query)}`); - + const status = req.body?.entry?.[0]?.changes?.[0]?.value?.statuses?.[0]; if (status) { @@ -481,7 +480,6 @@ export class GBMinService { if (challenge && val === challenge) { res.send(req.query['hub.challenge']); res.status(200); - GBLogEx.info(min, `Meta callback OK. ${JSON.stringify(req.query)}`); } else { res.status(401); } @@ -1096,7 +1094,7 @@ export class GBMinService { GBMinService.pidsConversation[conversationId] = pid; step.context.activity['pid'] = pid; - const auth = min.core.getParam(min.instance, 'Enable Authentication', null); + const auth = true; // min.core.getParam(min.instance, 'Enable Authentication', null); if (auth) { const res = await t.find({ pid: pid, handle: "users.csv", args: [`key={member.id}`] });