var mongoose = require('mongoose'),
  User = mongoose.model('User');

var crud = require('../controllers/crud.js');
var crudService = require('../services/crud.js');

exports.create = function(req, res, next) {

  if(req.locals.error) {
    return next();
  }
  req.body.watchers = [req.user];
  req.body.assign = req.user;
  req.body.circles = {};
  req.body.entity = req.body.entity || req.query.entity || 'task';

  var options = {
    includes: 'assign watchers project subTasks discussions',
    defaults: {
      project: undefined,
      assign: undefined,
      discussions: [],
      watchers: [],
      circles: {}
    },
  };
  var entity = crud(req.body.entity.toLowerCase() + 's', options);
  if(req.body.customId) {
    var entityService = crudService(req.body.entity.toLowerCase() + 's', options);
    entityService
      .read(null, req.user, req.acl, {customId: req.body.customId})
      .then(function(e) {
        if(_.isEmpty(e)) {
          entity.create(req, res, next);
        } else {
          req.locals.result = req.locals.result || {};
          req.locals.result = e;
          entity.update(req, res, next);
        }

      });
  } else entity.create(req, res, next);
};

@@ -27,19 +27,21 @@
 ngoose')
-,%0A 
+;%0Avar
  User = 
@@ -63,16 +63,43 @@
 'User');
+%0Avar _ = require('lodash');
 %0A%0Avar cr
@@ -1172,16 +1172,72 @@
      %7D%0A%0A
+      %7D)%0A      .catch(function(err) %7B%0A        next(err)%0A
       %7D)

Fix missing lodash in webhook controller