From adbf4b792be47fbea62bb60406351c01234935d1 Mon Sep 17 00:00:00 2001 From: Mark Vayngrib Date: Tue, 2 Jan 2018 10:49:24 -0500 Subject: [PATCH] fix: check for empty dated value --- lib/samplebot/customize.js | 6 +++--- src/samplebot/customize.ts | 15 ++++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/samplebot/customize.js b/lib/samplebot/customize.js index d3cef0e28..3dca5e163 100644 --- a/lib/samplebot/customize.js +++ b/lib/samplebot/customize.js @@ -15,7 +15,6 @@ const strategy_1 = require("./strategy"); const configure_1 = require("./configure"); const Errors = require("../errors"); const ONFIDO_PLUGIN_PATH = 'products.plugins.onfido'; -const emptyStringToUndefined = val => val === "" ? undefined : val; function customize(opts) { return __awaiter(this, void 0, void 0, function* () { let { lambda, bot, delayReady, event } = opts; @@ -34,11 +33,12 @@ function customize(opts) { Errors.ignore(err, Errors.NotFound); return undefined; }), - confy.termsAndConditions.getDatedValue().catch(err => { + confy.termsAndConditions.getDatedValue() + .then(datedValue => datedValue.value && datedValue) + .catch(err => { Errors.ignore(err, Errors.NotFound); return undefined; }) - .then(emptyStringToUndefined) ]); const { domain } = org; const namespace = domain.split('.').reverse().join('.'); diff --git a/src/samplebot/customize.ts b/src/samplebot/customize.ts index 76cf945c2..46ab2931c 100644 --- a/src/samplebot/customize.ts +++ b/src/samplebot/customize.ts @@ -8,7 +8,6 @@ import { createConf } from './configure' import Errors = require('../errors') const ONFIDO_PLUGIN_PATH = 'products.plugins.onfido' -const emptyStringToUndefined = val => val === "" ? undefined : val export async function customize (opts) { let { lambda, bot, delayReady, event } = opts @@ -27,12 +26,14 @@ export async function customize (opts) { Errors.ignore(err, Errors.NotFound) return undefined }), - confy.termsAndConditions.getDatedValue().catch(err => { - // TODO: maybe store in local fs instead of in memory - Errors.ignore(err, Errors.NotFound) - return undefined - }) - .then(emptyStringToUndefined) + confy.termsAndConditions.getDatedValue() + // ignore empty values + .then(datedValue => datedValue.value && datedValue) + .catch(err => { + // TODO: maybe store in local fs instead of in memory + Errors.ignore(err, Errors.NotFound) + return undefined + }) ]) const { domain } = org