Skip to content

Commit

Permalink
fix(core): add small safeguards (#5459)
Browse files Browse the repository at this point in the history
  • Loading branch information
allardy committed Sep 17, 2021
1 parent edac7c6 commit a1a83c8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions packages/bp/src/common/lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ const extend = langs => {
}

const squash = (space, root = {}, path = ''): { [key: string]: string } => {
if (!space) {
return {}
}

for (const [key, value] of Object.entries(space)) {
if (typeof value === 'object' && value !== null) {
squash(value, root, `${path}${key}.`)
Expand Down
14 changes: 9 additions & 5 deletions packages/bp/src/core/qna/qna-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,16 @@ export class QnaService {
direction: 'incoming',
handler: async (event: any, next) => {
if (!event.hasFlag(WellKnownFlags.SKIP_QNA_PROCESSING)) {
const { defaultLang, qnaDisabled } = await this._getBotConfig(event.botId)
if (defaultLang && !qnaDisabled) {
await this._processEvent(event, defaultLang)
try {
const { defaultLang, qnaDisabled } = await this._getBotConfig(event.botId)
if (defaultLang && !qnaDisabled) {
await this._processEvent(event, defaultLang)
}

next()
} catch (err) {
next(err)
}

next()
}
},
order: 130, // must be after the NLU middleware and before the dialog middleware
Expand Down

0 comments on commit a1a83c8

Please sign in to comment.