Skip to content

Commit

Permalink
context id shouldn't be required if sub/unsub-ing from user or contex…
Browse files Browse the repository at this point in the history
…t models
  • Loading branch information
Razvan Botea committed Oct 23, 2015
1 parent 0101d40 commit dd83526
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions controllers/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit dd83526

Please sign in to comment.