new(all): Facebook workplace support.

This commit is contained in:
Rodrigo Rodriguez 2021-07-06 13:18:38 -03:00
parent e9dd4acaf7
commit 43a8fe530f
7 changed files with 39 additions and 18 deletions

View file

@ -108,3 +108,11 @@ ALTER TABLE dbo.GuaribasInstance ADD
googlePrivateKey nvarchar(4000) NULL, googlePrivateKey nvarchar(4000) NULL,
googleProjectId nvarchar(255) NULL googleProjectId nvarchar(255) NULL
GO GO
# 2.0.119
ALTER TABLE dbo.GuaribasInstance ADD
facebookWorkplaceVerifyToken nvarchar(255) NULL,
facebookWorkplaceAppSecret nvarchar(255) NULL,
facebookWorkplaceAccessToken nvarchar(512) NULL
GO

8
package-lock.json generated
View file

@ -1,6 +1,6 @@
{ {
"name": "botserver", "name": "botserver",
"version": "2.0.121", "version": "2.0.126",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -5179,9 +5179,9 @@
} }
}, },
"botlib": { "botlib": {
"version": "1.8.3", "version": "1.9.2",
"resolved": "https://registry.npmjs.org/botlib/-/botlib-1.8.3.tgz", "resolved": "https://registry.npmjs.org/botlib/-/botlib-1.9.2.tgz",
"integrity": "sha512-NWVeSgavucALMJ6yZT7ld0v01mL3964+3OLCW8oW2nuFxG4eBEpNztsg5HKJWBKb9nbeNWU70ynstC43kMQ+uw==", "integrity": "sha512-um7oVLrh3xHruQu0N6K4FBYHEidhAdCtgG4U6IadYMIt8j2hjeC5d9mwhElXhu/Darx7TWwoV42TNMVWuTuhxw==",
"requires": { "requires": {
"async": "3.2.0", "async": "3.2.0",
"botbuilder": "4.13.5", "botbuilder": "4.13.5",

View file

@ -68,11 +68,11 @@
"bluebird": "3.7.2", "bluebird": "3.7.2",
"body-parser": "1.19.0", "body-parser": "1.19.0",
"botbuilder": "4.13.5", "botbuilder": "4.13.5",
"botbuilder-adapter-facebook": "^1.0.11", "botbuilder-adapter-facebook": "1.0.11",
"botbuilder-ai": "4.13.5", "botbuilder-ai": "4.13.5",
"botbuilder-dialogs": "4.13.5", "botbuilder-dialogs": "4.13.5",
"botframework-connector": "4.13.5", "botframework-connector": "4.13.5",
"botlib": "1.8.3", "botlib": "1.9.2",
"cli-spinner": "0.2.10", "cli-spinner": "0.2.10",
"core-js": "3.14.0", "core-js": "3.14.0",
"dotenv-extended": "2.9.0", "dotenv-extended": "2.9.0",

View file

@ -246,7 +246,7 @@ export class GBVMService extends GBService {
code = code.replace(/(\w+)\s*\=\s*get\s(.*)/gi, ($0, $1, $2) => { code = code.replace(/(\w+)\s*\=\s*get\s(.*)/gi, ($0, $1, $2) => {
if ($2.indexOf('http') !== -1) { if ($2.indexOf('http') !== -1) {
return `let ${$1} = sys().httpGet (${$2})`; return `let ${$1} = sys().getByHttp (${$2})`;
} else { } else {
return `let ${$1} = sys().get (${$2})`; return `let ${$1} = sys().get (${$2})`;
} }

View file

@ -60,7 +60,7 @@ export class SystemKeywords {
* Reference to the deployer service. * Reference to the deployer service.
*/ */
private readonly deployer: GBDeployer; private readonly deployer: GBDeployer;
dk: DialogKeywords; dk: DialogKeywords;
@ -77,11 +77,12 @@ export class SystemKeywords {
/** /**
* Retrives the content of a given URL. * Retrives the content of a given URL.
*/ */
public async getFileContents(url) { public async getFileContents(url, headers) {
const options = { const options = {
url: url, url: url,
method: 'GET', method: 'GET',
encoding: 'binary' encoding: 'binary',
headers: headers
}; };
return await request(options); // TODO: Check this. return await request(options); // TODO: Check this.
} }
@ -638,9 +639,10 @@ export class SystemKeywords {
* @example user = get "http://server/users/1" * @example user = get "http://server/users/1"
* *
*/ */
public async getByHttp(url: string) { public async getByHttp(url: string, headers: any) {
const options = { const options = {
uri: url uri: url,
headers: headers
}; };
let result = await request.get(options); let result = await request.get(options);

View file

@ -147,10 +147,19 @@ export class GuaribasInstance extends Model<GuaribasInstance>
@Column({ type: DataType.STRING(4000) }) @Column({ type: DataType.STRING(4000) })
public googlePrivateKey: string; public googlePrivateKey: string;
@Column @Column
public googleProjectId: string; public googleProjectId: string;
@Column({ type: DataType.STRING(255) })
facebookWorkplaceVerifyToken: string;
@Column({ type: DataType.STRING(255) })
facebookWorkplaceAppSecret: string;
@Column({ type: DataType.STRING(512) })
facebookWorkplaceAccessToken: string;
@Column @Column
public whatsappBotKey: string; public whatsappBotKey: string;

View file

@ -638,12 +638,12 @@ export class GBMinService {
if (GBServer.globals.minBoot === undefined) { if (GBServer.globals.minBoot === undefined) {
GBServer.globals.minBoot = min; GBServer.globals.minBoot = min;
} }
if (process.env.FACEBOOK_VERIFY_TOKEN) { if (min.instance.facebookWorkplaceVerifyToken) {
min['fbAdapter'] = new FacebookAdapter({ min['fbAdapter'] = new FacebookAdapter({
verify_token: process.env.FACEBOOK_VERIFY_TOKEN, verify_token: min.instance.facebookWorkplaceVerifyToken,
app_secret: process.env.FACEBOOK_APP_SECRET, app_secret: min.instance.facebookWorkplaceAppSecret,
access_token: process.env.FACEBOOK_ACCESS_TOKEN access_token: min.instance.facebookWorkplaceAccessToken
}); });
} }
// TODO: min.appPackages = core.getPackagesByInstanceId(min.instance.instanceId); // TODO: min.appPackages = core.getPackagesByInstanceId(min.instance.instanceId);
@ -869,6 +869,8 @@ export class GBMinService {
user.welcomed = true; user.welcomed = true;
GBLog.info(`Auto start (teams) dialog is now being called: ${startDialog} for ${min.instance.botId}...`); GBLog.info(`Auto start (teams) dialog is now being called: ${startDialog} for ${min.instance.botId}...`);
await GBVMService.callVM(startDialog.toLowerCase(), min, step, this.deployer); await GBVMService.callVM(startDialog.toLowerCase(), min, step, this.deployer);
} }
} }
} }