fix(all): Minor changes in PROD.
This commit is contained in:
parent
a969abbcc4
commit
a60581bd32
5 changed files with 69 additions and 62 deletions
0
gbot.sh
Normal file → Executable file
0
gbot.sh
Normal file → Executable file
|
@ -717,7 +717,7 @@ export class DialogKeywords {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public async hear({ pid, kind, args }) {
|
public async hear({ pid, kind, args }) {
|
||||||
let { min, user, params } = await DialogKeywords.getProcessInfo(pid);
|
let { min, user, params } = await DialogKeywords.getProcessInfo(pid);
|
||||||
|
|
||||||
// Handles first arg as an array of args.
|
// Handles first arg as an array of args.
|
||||||
|
|
||||||
|
|
|
@ -201,10 +201,10 @@ export class GBMinService {
|
||||||
pingSendTimeout: null,
|
pingSendTimeout: null,
|
||||||
keepAliveTimeout: null,
|
keepAliveTimeout: null,
|
||||||
listeners: {
|
listeners: {
|
||||||
unsubscribed(subscriptions: number): void {},
|
unsubscribed(subscriptions: number): void { },
|
||||||
subscribed(subscriptions: number): void {},
|
subscribed(subscriptions: number): void { },
|
||||||
disconnected(remoteId: string, connections: number): void {},
|
disconnected(remoteId: string, connections: number): void { },
|
||||||
connected(remoteId: string, connections: number): void {},
|
connected(remoteId: string, connections: number): void { },
|
||||||
messageIn(...params): void {
|
messageIn(...params): void {
|
||||||
GBLogEx.info(0, '[IN] ' + params);
|
GBLogEx.info(0, '[IN] ' + params);
|
||||||
},
|
},
|
||||||
|
@ -239,7 +239,7 @@ export class GBMinService {
|
||||||
GBLogEx.info(0, 'API RPC HTTP Server started.');
|
GBLogEx.info(0, 'API RPC HTTP Server started.');
|
||||||
|
|
||||||
// Loads schedules.
|
// Loads schedules.
|
||||||
|
|
||||||
GBLog.info(`Preparing SET SCHEDULE dialog calls...`);
|
GBLog.info(`Preparing SET SCHEDULE dialog calls...`);
|
||||||
const service = new ScheduleServices();
|
const service = new ScheduleServices();
|
||||||
await service.scheduleAll();
|
await service.scheduleAll();
|
||||||
|
@ -285,7 +285,7 @@ export class GBMinService {
|
||||||
/**
|
/**
|
||||||
* Unmounts the bot web site (default.gbui) secure domain, if any.
|
* Unmounts the bot web site (default.gbui) secure domain, if any.
|
||||||
*/
|
*/
|
||||||
public async unloadDomain(instance: IGBInstance) {}
|
public async unloadDomain(instance: IGBInstance) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mount the instance by creating an BOT Framework bot object,
|
* Mount the instance by creating an BOT Framework bot object,
|
||||||
|
@ -562,9 +562,8 @@ export class GBMinService {
|
||||||
min.instance.authenticatorTenant,
|
min.instance.authenticatorTenant,
|
||||||
'/oauth2/authorize'
|
'/oauth2/authorize'
|
||||||
);
|
);
|
||||||
authorizationUrl = `${authorizationUrl}?response_type=code&client_id=${
|
authorizationUrl = `${authorizationUrl}?response_type=code&client_id=${min.instance.marketplaceId
|
||||||
min.instance.marketplaceId
|
}&redirect_uri=${urlJoin(min.instance.botEndpoint, min.instance.botId, 'token')}`;
|
||||||
}&redirect_uri=${urlJoin(min.instance.botEndpoint, min.instance.botId, 'token')}`;
|
|
||||||
GBLog.info(`HandleOAuthRequests: ${authorizationUrl}.`);
|
GBLog.info(`HandleOAuthRequests: ${authorizationUrl}.`);
|
||||||
res.redirect(authorizationUrl);
|
res.redirect(authorizationUrl);
|
||||||
});
|
});
|
||||||
|
@ -1040,20 +1039,7 @@ export class GBMinService {
|
||||||
} else {
|
} else {
|
||||||
GBLog.info(`Person added to conversation: ${member.name}`);
|
GBLog.info(`Person added to conversation: ${member.name}`);
|
||||||
|
|
||||||
if (GBMinService.userMobile(step)) {
|
return;
|
||||||
if (
|
|
||||||
startDialog &&
|
|
||||||
!min['conversationWelcomed'][step.context.activity.conversation.id] &&
|
|
||||||
!step.context.activity['group']
|
|
||||||
) {
|
|
||||||
await sec.setParam(userId, 'welcomed', 'true');
|
|
||||||
min['conversationWelcomed'][step.context.activity.conversation.id] = true;
|
|
||||||
GBLog.info(
|
|
||||||
`Auto start (whatsapp) dialog is now being called: ${startDialog} for ${min.instance.instanceId}...`
|
|
||||||
);
|
|
||||||
await GBVMService.callVM(startDialog.toLowerCase(), min, step, user, this.deployer, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (context.activity.type === 'message') {
|
} else if (context.activity.type === 'message') {
|
||||||
// Processes messages activities.
|
// Processes messages activities.
|
||||||
|
@ -1065,9 +1051,8 @@ export class GBMinService {
|
||||||
await this.processEventActivity(min, user, context, step);
|
await this.processEventActivity(min, user, context, step);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const msg = `ERROR: ${error.message} ${error.stack} ${error.error ? error.error.body : ''} ${
|
const msg = `ERROR: ${error.message} ${error.stack} ${error.error ? error.error.body : ''} ${error.error ? (error.error.stack ? error.error.stack : '') : ''
|
||||||
error.error ? (error.error.stack ? error.error.stack : '') : ''
|
}`;
|
||||||
}`;
|
|
||||||
GBLog.error(msg);
|
GBLog.error(msg);
|
||||||
|
|
||||||
await min.conversationalService.sendText(
|
await min.conversationalService.sendText(
|
||||||
|
@ -1081,6 +1066,7 @@ export class GBMinService {
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
await adapter['processActivity'](req, res, handler);
|
await adapter['processActivity'](req, res, handler);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.code === 401) {
|
if (error.code === 401) {
|
||||||
|
@ -1133,40 +1119,40 @@ export class GBMinService {
|
||||||
/**
|
/**
|
||||||
* Private handler which receives the Attachment and persists to disk.
|
* Private handler which receives the Attachment and persists to disk.
|
||||||
* during a HEAR attachment AS FILE upload.
|
* during a HEAR attachment AS FILE upload.
|
||||||
*/
|
*/
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
private static async downloadAttachmentAndWrite(attachment) {
|
private static async downloadAttachmentAndWrite(attachment) {
|
||||||
const url = attachment.contentUrl;
|
const url = attachment.contentUrl;
|
||||||
const localFolder = Path.join('work');
|
const localFolder = Path.join('work');
|
||||||
const path = DialogKeywords.getGBAIPath(this['min'].botId);
|
const path = DialogKeywords.getGBAIPath(this['min'].botId);
|
||||||
const localFileName = Path.join(localFolder, path, 'uploads',
|
const localFileName = Path.join(localFolder, path, 'uploads',
|
||||||
attachment.name
|
attachment.name
|
||||||
);
|
);
|
||||||
|
|
||||||
let buffer;
|
let buffer;
|
||||||
if (url.startsWith('data:')) {
|
if (url.startsWith('data:')) {
|
||||||
const base64Data = url.split(';base64,')[1];
|
const base64Data = url.split(';base64,')[1];
|
||||||
buffer = Buffer.from(base64Data, 'base64');
|
buffer = Buffer.from(base64Data, 'base64');
|
||||||
} else {
|
} else {
|
||||||
const options = {
|
const options = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
encoding: 'binary'
|
encoding: 'binary'
|
||||||
};
|
|
||||||
const res = await fetch(url, options);
|
|
||||||
buffer = arrayBufferToBuffer(await res.arrayBuffer());
|
|
||||||
}
|
|
||||||
|
|
||||||
Fs.writeFileSync(localFileName, buffer);
|
|
||||||
|
|
||||||
return {
|
|
||||||
fileName:
|
|
||||||
attachment.name
|
|
||||||
,
|
|
||||||
localPath: localFileName
|
|
||||||
};
|
};
|
||||||
|
const res = await fetch(url, options);
|
||||||
|
buffer = arrayBufferToBuffer(await res.arrayBuffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Fs.writeFileSync(localFileName, buffer);
|
||||||
|
|
||||||
|
return {
|
||||||
|
fileName:
|
||||||
|
attachment.name
|
||||||
|
,
|
||||||
|
localPath: localFileName
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -1233,6 +1219,27 @@ export class GBMinService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GBMinService.userMobile(step)) {
|
||||||
|
const startDialog = user.hearOnDialog
|
||||||
|
? user.hearOnDialog
|
||||||
|
: min.core.getParam(min.instance, 'Start Dialog', null);
|
||||||
|
|
||||||
|
if (
|
||||||
|
startDialog &&
|
||||||
|
!min['conversationWelcomed'][step.context.activity.conversation.id] &&
|
||||||
|
!step.context.activity['group']
|
||||||
|
) {
|
||||||
|
await sec.setParam(userId, 'welcomed', 'true');
|
||||||
|
min['conversationWelcomed'][step.context.activity.conversation.id] = true;
|
||||||
|
GBLog.info(
|
||||||
|
`Auto start (whatsapp) dialog is now being called: ${startDialog} for ${min.instance.instanceId}...`
|
||||||
|
);
|
||||||
|
await GBVMService.callVM(startDialog.toLowerCase(), min, step, user, this.deployer, false);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Prepare Promises to download each attachment and then execute each Promise.
|
// Prepare Promises to download each attachment and then execute each Promise.
|
||||||
if (step.context.activity.attachments) {
|
if (step.context.activity.attachments) {
|
||||||
const promises = step.context.activity.attachments.map(
|
const promises = step.context.activity.attachments.map(
|
||||||
|
@ -1264,7 +1271,7 @@ export class GBMinService {
|
||||||
accum.push(result);
|
accum.push(result);
|
||||||
return accum;
|
return accum;
|
||||||
}, []) as GBFile[];
|
}, []) as GBFile[];
|
||||||
|
|
||||||
if (min.cbMap[userId] && min.cbMap[userId].promise == '!GBHEAR') {
|
if (min.cbMap[userId] && min.cbMap[userId].promise == '!GBHEAR') {
|
||||||
if (results.length > 1) {
|
if (results.length > 1) {
|
||||||
throw new Error('It is only possible to upload one file per message, right now.');
|
throw new Error('It is only possible to upload one file per message, right now.');
|
||||||
|
@ -1465,7 +1472,7 @@ export class GBMinService {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (min.cbMap[userId] && min.cbMap[userId].promise == '!GBHEAR') {
|
if (min.cbMap[userId] && min.cbMap[userId].promise === '!GBHEAR') {
|
||||||
min.cbMap[userId].promise = text;
|
min.cbMap[userId].promise = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -333,7 +333,7 @@ export class GBSSR {
|
||||||
url === '/' || url === '' ? `index.html` : url
|
url === '/' || url === '' ? `index.html` : url
|
||||||
);
|
);
|
||||||
if (GBServer.globals.wwwroot && url === '/'){
|
if (GBServer.globals.wwwroot && url === '/'){
|
||||||
path = GBServer.globals.wwwroot + "\\index.html";
|
path = GBServer.globals.wwwroot + "/index.html"; // TODO.
|
||||||
}
|
}
|
||||||
if (Fs.existsSync(path)) {
|
if (Fs.existsSync(path)) {
|
||||||
if (min) {
|
if (min) {
|
||||||
|
|
|
@ -189,7 +189,7 @@ export class AskDialog extends IGBDialog {
|
||||||
// When no text is typed, the start dialog is invoked again
|
// When no text is typed, the start dialog is invoked again
|
||||||
// when people type just the @botName in MSTEAMS for example.
|
// when people type just the @botName in MSTEAMS for example.
|
||||||
|
|
||||||
if (!text) {
|
if (!text && step.context.activity.channelId === 'msteams') {
|
||||||
const startDialog = min.core.getParam(min.instance, 'Start Dialog', null);
|
const startDialog = min.core.getParam(min.instance, 'Start Dialog', null);
|
||||||
if (startDialog) {
|
if (startDialog) {
|
||||||
await GBVMService.callVM(startDialog.toLowerCase().trim(), min, step, user, this.deployer, false);
|
await GBVMService.callVM(startDialog.toLowerCase().trim(), min, step, user, this.deployer, false);
|
||||||
|
|
Loading…
Add table
Reference in a new issue