fix(core.gbapp): SaaS missing in PROD.
This commit is contained in:
parent
bb456cae11
commit
fe9548ccc8
4 changed files with 15 additions and 63 deletions
|
@ -65,8 +65,8 @@ import { GBUtil } from '../../../src/util.js';
|
||||||
import { GBLogEx } from './GBLogEx.js';
|
import { GBLogEx } from './GBLogEx.js';
|
||||||
import { GBDeployer } from './GBDeployer.js';
|
import { GBDeployer } from './GBDeployer.js';
|
||||||
import { SystemKeywords } from '../../basic.gblib/services/SystemKeywords.js';
|
import { SystemKeywords } from '../../basic.gblib/services/SystemKeywords.js';
|
||||||
import { DialogKeywords } from '../../basic.gblib/services/DialogKeywords.js';
|
|
||||||
import csvdb from 'csv-database';
|
import csvdb from 'csv-database';
|
||||||
|
import { SaaSPackage } from '../../saas.gbapp/index.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GBCoreService contains main logic for handling storage services related
|
* GBCoreService contains main logic for handling storage services related
|
||||||
|
@ -503,7 +503,8 @@ await fs.writeFile('.env', env);
|
||||||
GBSharePointPackage,
|
GBSharePointPackage,
|
||||||
GBGoogleChatPackage,
|
GBGoogleChatPackage,
|
||||||
GBBasicPackage,
|
GBBasicPackage,
|
||||||
GBHubSpotPackage
|
GBHubSpotPackage,
|
||||||
|
SaaSPackage
|
||||||
],
|
],
|
||||||
async e => {
|
async e => {
|
||||||
GBLogEx.info(0, `Loading sys package: ${e.name}...`);
|
GBLogEx.info(0, `Loading sys package: ${e.name}...`);
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
import { IGBDialog, GBMinInstance } from 'botlib';
|
import { IGBDialog, GBMinInstance } from 'botlib';
|
||||||
import { Messages } from '../strings.js';
|
import { Messages } from '../strings.js';
|
||||||
import { MainService } from '../service/MainService.js';
|
import { MainService } from '../service/MainService.js';
|
||||||
import { Package } from '../index.js';
|
import { SaaSPackage } from '../index.js';
|
||||||
import { CollectionUtil } from 'pragmatismo-io-framework';
|
import { CollectionUtil } from 'pragmatismo-io-framework';
|
||||||
|
|
||||||
export class NewUserDialog extends IGBDialog {
|
export class NewUserDialog extends IGBDialog {
|
||||||
|
@ -243,7 +243,7 @@ export class NewUserDialog extends IGBDialog {
|
||||||
min,
|
min,
|
||||||
botName,
|
botName,
|
||||||
'999999999',
|
'999999999',
|
||||||
'operations@pragmatismo.cloud',
|
'email@doman.cloud',
|
||||||
'5521999998888',
|
'5521999998888',
|
||||||
botName,
|
botName,
|
||||||
null,
|
null,
|
||||||
|
@ -289,7 +289,7 @@ export class NewUserDialog extends IGBDialog {
|
||||||
|
|
||||||
return await step.replaceDialog('/profile_name', step.activeDialog.state.options);
|
return await step.replaceDialog('/profile_name', step.activeDialog.state.options);
|
||||||
} else {
|
} 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.name = name;
|
||||||
step.activeDialog.state.options.mobile = mobile;
|
step.activeDialog.state.options.mobile = mobile;
|
||||||
|
|
||||||
|
|
|
@ -32,16 +32,13 @@
|
||||||
|
|
||||||
import { IGBPackage, GBMinInstance, IGBCoreService, GBLog, IGBAdminService, GBDialogStep } from 'botlib'
|
import { IGBPackage, GBMinInstance, IGBCoreService, GBLog, IGBAdminService, GBDialogStep } from 'botlib'
|
||||||
import { Sequelize } from 'sequelize-typescript'
|
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 { CollectionUtil } from 'pragmatismo-io-framework';
|
||||||
import { NewUserDialog } from './dialog/NewUserDialog'
|
import { NewUserDialog } from './dialog/NewUserDialog.js'
|
||||||
const MicrosoftGraph = require("@microsoft/microsoft-graph-client");
|
|
||||||
|
|
||||||
const cron = require('node-cron');
|
export class SaaSPackage implements IGBPackage {
|
||||||
|
|
||||||
export class Package implements IGBPackage {
|
|
||||||
sysPackages: IGBPackage[]
|
sysPackages: IGBPackage[]
|
||||||
adminService: IGBAdminService;
|
adminService: IGBAdminService;
|
||||||
public static welcomes = {};
|
public static welcomes = {};
|
||||||
|
@ -95,11 +92,6 @@ export class Package implements IGBPackage {
|
||||||
this.adminService = min.adminService;
|
this.adminService = min.adminService;
|
||||||
this.instanceId = min.instanceId;
|
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<void> {
|
async unloadPackage(core: IGBCoreService): Promise<void> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -158,10 +111,9 @@ export class Package implements IGBPackage {
|
||||||
|
|
||||||
let gboService = min.gbappServices['gboService'];
|
let gboService = min.gbappServices['gboService'];
|
||||||
|
|
||||||
|
|
||||||
// Gets the sendToDevice method of whatsapp.gblib and setups scheduler.
|
// 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);
|
const sendToDevice = min.whatsAppDirectLine.sendToDevice.bind(min.whatsAppDirectLine);
|
||||||
this.setupScheduler(min, sendToDevice);
|
this.setupScheduler(min, sendToDevice);
|
||||||
this.notifyJob(sendToDevice);
|
this.notifyJob(sendToDevice);
|
||||||
|
@ -183,7 +135,7 @@ export class Package implements IGBPackage {
|
||||||
|
|
||||||
const from = data.from;
|
const from = data.from;
|
||||||
const fromName = data.fromName;
|
const fromName = data.fromName;
|
||||||
Package.welcomes[from] = fromName;
|
SaaSPackage.welcomes[from] = fromName;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -30,8 +30,7 @@
|
||||||
|
|
||||||
"use strict"
|
"use strict"
|
||||||
|
|
||||||
import { MainService } from "./MainService";
|
import { MainService } from "./MainService.js";
|
||||||
const request = require('request-promise-native');
|
|
||||||
|
|
||||||
export class MSSubscriptionService {
|
export class MSSubscriptionService {
|
||||||
|
|
||||||
|
@ -49,7 +48,7 @@ export class MSSubscriptionService {
|
||||||
'x-ms-marketplace-token': token
|
'x-ms-marketplace-token': token
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let result = await request.get(options);
|
let result = null; // TODO: await fetch({});
|
||||||
let data = JSON.parse(result);
|
let data = JSON.parse(result);
|
||||||
|
|
||||||
const additionalData = {
|
const additionalData = {
|
||||||
|
@ -107,7 +106,7 @@ export class MSSubscriptionService {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
result = await request.get(options);
|
result = null; // TODO: fetch.
|
||||||
data = JSON.parse(result);
|
data = JSON.parse(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue