fix(whatsapp.gblib): Web can show images again and working directory on startup being created.
This commit is contained in:
parent
2b4fb68022
commit
8d512ca6a1
2 changed files with 26 additions and 11 deletions
|
@ -388,8 +388,17 @@ export class KBService {
|
||||||
html = marked(answer.content);
|
html = marked(answer.content);
|
||||||
if (channel === 'webchat' &&
|
if (channel === 'webchat' &&
|
||||||
GBConfigService.get('DISABLE_WEB') !== 'true') {
|
GBConfigService.get('DISABLE_WEB') !== 'true') {
|
||||||
|
await this.sendMarkdownToWeb(step, conversationalService, html, answer);
|
||||||
|
}
|
||||||
|
else if (channel === 'whatsapp') {
|
||||||
|
await this.sendMarkdownToMobile(step, answer, conversationalService, min);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async sendMarkdownToWeb(step: GBDialogStep, conversationalService: IGBConversationalService, html: string, answer: GuaribasAnswer) {
|
||||||
const locale = step.context.activity.locale;
|
const locale = step.context.activity.locale;
|
||||||
await step.context.sendActivity(Messages[locale].will_answer_projector);
|
await step.context.sendActivity(Messages[locale].will_answer_projector);
|
||||||
|
html = html.replace(/src\=\"kb\//g, `src=\"../kb/`);
|
||||||
await conversationalService.sendEvent(step, 'play', {
|
await conversationalService.sendEvent(step, 'play', {
|
||||||
playerType: 'markdown',
|
playerType: 'markdown',
|
||||||
data: {
|
data: {
|
||||||
|
@ -400,10 +409,6 @@ export class KBService {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (channel === 'whatsapp') {
|
|
||||||
await this.sendMarkdownToMobile(step, answer, conversationalService, min);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async sendMarkdownToMobile(step: GBDialogStep, answer: GuaribasAnswer, conversationalService: IGBConversationalService, min: GBMinInstance) {
|
private async sendMarkdownToMobile(step: GBDialogStep, answer: GuaribasAnswer, conversationalService: IGBConversationalService, min: GBMinInstance) {
|
||||||
|
|
||||||
|
|
10
src/app.ts
10
src/app.ts
|
@ -38,6 +38,8 @@
|
||||||
|
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const bodyParser = require('body-parser');
|
const bodyParser = require('body-parser');
|
||||||
|
import * as fs from 'fs';
|
||||||
|
var mkdirp = require('mkdirp');
|
||||||
|
|
||||||
import { GBLog, IGBCoreService, IGBInstance, IGBPackage, GBMinInstance } from 'botlib';
|
import { GBLog, IGBCoreService, IGBInstance, IGBPackage, GBMinInstance } from 'botlib';
|
||||||
import { GBAdminService } from '../packages/admin.gbapp/services/GBAdminService';
|
import { GBAdminService } from '../packages/admin.gbapp/services/GBAdminService';
|
||||||
|
@ -88,6 +90,14 @@ export class GBServer {
|
||||||
server.use(bodyParser.json());
|
server.use(bodyParser.json());
|
||||||
server.use(bodyParser.urlencoded({ extended: true }));
|
server.use(bodyParser.urlencoded({ extended: true }));
|
||||||
|
|
||||||
|
// Creates working directory.
|
||||||
|
|
||||||
|
const workDir = 'workDir';
|
||||||
|
if (!fs.existsSync(workDir)){
|
||||||
|
mkdirp.sync(workDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
server.listen(port, () => {
|
server.listen(port, () => {
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Reference in a new issue