Skip to content

Commit

Permalink
fix(whatsapp.gblib): Web can show images again and working directory …
Browse files Browse the repository at this point in the history
…on startup being created.
  • Loading branch information
rodrigorodriguez committed Aug 26, 2019
1 parent 2b4fb68 commit 8d512ca
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
27 changes: 16 additions & 11 deletions packages/kb.gbapp/services/KBService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,23 +388,28 @@ export class KBService {
html = marked(answer.content);
if (channel === 'webchat' &&
GBConfigService.get('DISABLE_WEB') !== 'true') {
const locale = step.context.activity.locale;
await step.context.sendActivity(Messages[locale].will_answer_projector);
await conversationalService.sendEvent(step, 'play', {
playerType: 'markdown',
data: {
content: html,
answer: answer,
prevId: answer.prevId,
nextId: answer.nextId
}
});
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;
await step.context.sendActivity(Messages[locale].will_answer_projector);
html = html.replace(/src\=\"kb\//g, `src=\"../kb/`);
await conversationalService.sendEvent(step, 'play', {
playerType: 'markdown',
data: {
content: html,
answer: answer,
prevId: answer.prevId,
nextId: answer.nextId
}
});
}

private async sendMarkdownToMobile(step: GBDialogStep, answer: GuaribasAnswer, conversationalService: IGBConversationalService, min: GBMinInstance) {

let text = answer.content;
Expand Down
10 changes: 10 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

const express = require('express');
const bodyParser = require('body-parser');
import * as fs from 'fs';
var mkdirp = require('mkdirp');

import { GBLog, IGBCoreService, IGBInstance, IGBPackage, GBMinInstance } from 'botlib';
import { GBAdminService } from '../packages/admin.gbapp/services/GBAdminService';
Expand Down Expand Up @@ -88,6 +90,14 @@ export class GBServer {
server.use(bodyParser.json());
server.use(bodyParser.urlencoded({ extended: true }));

// Creates working directory.

const workDir = 'workDir';
if (!fs.existsSync(workDir)){
mkdirp.sync(workDir);
}


server.listen(port, () => {
(async () => {
try {
Expand Down

0 comments on commit 8d512ca

Please sign in to comment.