diff --git a/packages/core.gbapp/services/GBCoreService.ts b/packages/core.gbapp/services/GBCoreService.ts index 17fef107..031f2a5a 100644 --- a/packages/core.gbapp/services/GBCoreService.ts +++ b/packages/core.gbapp/services/GBCoreService.ts @@ -65,8 +65,8 @@ import { GBUtil } from '../../../src/util.js'; import { GBLogEx } from './GBLogEx.js'; import { GBDeployer } from './GBDeployer.js'; import { SystemKeywords } from '../../basic.gblib/services/SystemKeywords.js'; -import { DialogKeywords } from '../../basic.gblib/services/DialogKeywords.js'; import csvdb from 'csv-database'; +import { SaaSPackage } from '../../saas.gbapp/index.js'; /** * GBCoreService contains main logic for handling storage services related @@ -503,7 +503,8 @@ await fs.writeFile('.env', env); GBSharePointPackage, GBGoogleChatPackage, GBBasicPackage, - GBHubSpotPackage + GBHubSpotPackage, + SaaSPackage ], async e => { GBLogEx.info(0, `Loading sys package: ${e.name}...`); diff --git a/packages/saas.gbapp/dialog/NewUserDialog.ts b/packages/saas.gbapp/dialog/NewUserDialog.ts index 9082c514..1794e1dd 100755 --- a/packages/saas.gbapp/dialog/NewUserDialog.ts +++ b/packages/saas.gbapp/dialog/NewUserDialog.ts @@ -33,7 +33,7 @@ import { IGBDialog, GBMinInstance } from 'botlib'; import { Messages } from '../strings.js'; import { MainService } from '../service/MainService.js'; -import { Package } from '../index.js'; +import { SaaSPackage } from '../index.js'; import { CollectionUtil } from 'pragmatismo-io-framework'; export class NewUserDialog extends IGBDialog { @@ -243,7 +243,7 @@ export class NewUserDialog extends IGBDialog { min, botName, '999999999', - 'operations@pragmatismo.cloud', + 'email@doman.cloud', '5521999998888', botName, null, @@ -289,7 +289,7 @@ export class NewUserDialog extends IGBDialog { return await step.replaceDialog('/profile_name', step.activeDialog.state.options); } else { - const name = Package.welcomes ? Package.welcomes[mobile] : null; + const name = SaaSPackage.welcomes ? SaaSPackage.welcomes[mobile] : null; step.activeDialog.state.options.name = name; step.activeDialog.state.options.mobile = mobile; diff --git a/packages/saas.gbapp/index.ts b/packages/saas.gbapp/index.ts index 38be1209..3e8ea707 100755 --- a/packages/saas.gbapp/index.ts +++ b/packages/saas.gbapp/index.ts @@ -32,16 +32,13 @@ import { IGBPackage, GBMinInstance, IGBCoreService, GBLog, IGBAdminService, GBDialogStep } from 'botlib' import { Sequelize } from 'sequelize-typescript' -import { GBOnlineSubscription } from './model/MainModel' +import { GBOnlineSubscription } from './model/MainModel.js' -import { MSSubscriptionService } from './service/MSSubscription' +import { MSSubscriptionService } from './service/MSSubscription.js' import { CollectionUtil } from 'pragmatismo-io-framework'; -import { NewUserDialog } from './dialog/NewUserDialog' -const MicrosoftGraph = require("@microsoft/microsoft-graph-client"); +import { NewUserDialog } from './dialog/NewUserDialog.js' -const cron = require('node-cron'); - -export class Package implements IGBPackage { +export class SaaSPackage implements IGBPackage { sysPackages: IGBPackage[] adminService: IGBAdminService; public static welcomes = {}; @@ -95,11 +92,6 @@ export class Package implements IGBPackage { this.adminService = min.adminService; this.instanceId = min.instanceId; - cron.schedule(schedule, async () => { - GBLog.info( 'Sending Tasks notifications if applies...'); - await this.notifyJob(sendToDevice); - }, options); - GBLog.info( 'Running Reviews notifications 09:30 from Monday to Friday...'); } /** @@ -111,45 +103,6 @@ export class Package implements IGBPackage { } - - public async getTasksMarkdown(packagePath, file) { - - let token = - await this.adminService.acquireElevatedToken(this.instanceId); - - let client = MicrosoftGraph.Client.init({ - authProvider: done => { - done(null, token); - } - }); - let siteId = process.env.STORAGE_SITE_ID; - let libraryId = process.env.STORAGE_LIBRARY; - - let res = await client.api( - `https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${libraryId}/drive/root:${packagePath}:/children`) - .get(); - - let document = res.value.filter(m => { - return m.name === file - }); - - let results = await client.api( - `https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${libraryId}/drive/items/${document[0].id}/workbook/worksheets('Tasks')/range(address='A1:A10')`) - .get(); - - let index = 1; - let md = `*Tasks*\n`; - - for (; index <= 10; index++) { - const row = results.text[index]; - if (row !== undefined) { - md = `${md}\n *${index}*. ${row[0]}`; - } - } - - return md; - } - async unloadPackage(core: IGBCoreService): Promise { } @@ -158,10 +111,9 @@ export class Package implements IGBPackage { let gboService = min.gbappServices['gboService']; - // Gets the sendToDevice method of whatsapp.gblib and setups scheduler. - if (min.whatsAppDirectLine !== undefined && min.botId === "Pragmatismo") { + if (min.whatsAppDirectLine !== undefined) { const sendToDevice = min.whatsAppDirectLine.sendToDevice.bind(min.whatsAppDirectLine); this.setupScheduler(min, sendToDevice); this.notifyJob(sendToDevice); @@ -183,7 +135,7 @@ export class Package implements IGBPackage { const from = data.from; const fromName = data.fromName; - Package.welcomes[from] = fromName; + SaaSPackage.welcomes[from] = fromName; break; default: diff --git a/packages/saas.gbapp/service/MSSubscription.ts b/packages/saas.gbapp/service/MSSubscription.ts index 0200eb1e..7d75343f 100755 --- a/packages/saas.gbapp/service/MSSubscription.ts +++ b/packages/saas.gbapp/service/MSSubscription.ts @@ -30,8 +30,7 @@ "use strict" -import { MainService } from "./MainService"; -const request = require('request-promise-native'); +import { MainService } from "./MainService.js"; export class MSSubscriptionService { @@ -49,7 +48,7 @@ export class MSSubscriptionService { 'x-ms-marketplace-token': token } }; - let result = await request.get(options); + let result = null; // TODO: await fetch({}); let data = JSON.parse(result); const additionalData = { @@ -107,7 +106,7 @@ export class MSSubscriptionService { } }; - result = await request.get(options); + result = null; // TODO: fetch. data = JSON.parse(result); }