From 4d3c0db5c3e4b1a2f9f65fbd7370d088fbe16b0f Mon Sep 17 00:00:00 2001 From: Muthu Kumar Date: Wed, 18 Jul 2018 12:31:18 +0530 Subject: [PATCH] [validator] fix - app crashing on edited message --- lib/validator.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/validator.js b/lib/validator.js index 743f7fc..ab05ce8 100644 --- a/lib/validator.js +++ b/lib/validator.js @@ -4,8 +4,9 @@ const responder = require('./responseHandler.js'); const validate = (ctx, next) => { - if(!path(['update', 'message', 'from', 'id'], ctx)) return Promise.reject(ctx); - return ((ctx.update.message.from.id === config.masterID) + const fromId = path(['update', 'message', 'from', 'id'], ctx); + if(!fromId) return; + return ((fromId === config.masterID) ? Promise.resolve(ctx) : Promise.reject(ctx)) .then(next)