From dd8352695edef296fa1045ebf1af3711982d94ca Mon Sep 17 00:00:00 2001 From: Razvan Botea Date: Fri, 23 Oct 2015 18:13:09 +0300 Subject: [PATCH] context id shouldn't be required if sub/unsub-ing from user or context models --- controllers/object.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/controllers/object.js b/controllers/object.js index 056d5c9..cf59ca9 100644 --- a/controllers/object.js +++ b/controllers/object.js @@ -115,8 +115,10 @@ router.post('/subscribe', function(req, res, next) { deviceId = req._telepat.device_id, appId = req._telepat.applicationId; - if (!context) - return next(new Models.TelepatError(Models.TelepatError.errors.MissingRequiredField, ['channel.context'])); + if (['user', 'context'].indexOf(mdl) === -1) { + if (!context) + return next(new Models.TelepatError(Models.TelepatError.errors.MissingRequiredField, ['channel.context'])); + } var channelObject = new Models.Channel(appId); @@ -247,8 +249,10 @@ router.post('/unsubscribe', function(req, res, next) { deviceId = req._telepat.device_id, appId = req._telepat.applicationId; - if (!context) - return next(new Models.TelepatError(Models.TelepatError.errors.MissingRequiredField, ['channel.context'])); + if (['user', 'context'].indexOf(mdl) === -1) { + if (!context) + return next(new Models.TelepatError(Models.TelepatError.errors.MissingRequiredField, ['channel.context'])); + } var channelObject = new Models.Channel(appId);